Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reporting services 如何走动'#错误';MS Report Builder中的函数何时计算空值?_Reporting Services - Fatal编程技术网

Reporting services 如何走动'#错误';MS Report Builder中的函数何时计算空值?

Reporting services 如何走动'#错误';MS Report Builder中的函数何时计算空值?,reporting-services,Reporting Services,我希望我的标题足够清楚。我在MS Report Builder中工作,使用一个函数将正则表达式应用于查询的值,以便返回某个子字符串。正则表达式可以很好地工作,因此我将在这里演示一个更简单的版本,以减少冗长。以下是我方程式的要点: =IIF(Len(Fields!CourtLocation.Value)

我希望我的标题足够清楚。我在MS Report Builder中工作,使用一个函数将正则表达式应用于查询的值,以便返回某个子字符串。正则表达式可以很好地工作,因此我将在这里演示一个更简单的版本,以减少冗长。以下是我方程式的要点:

=IIF(Len(Fields!CourtLocation.Value)<1,“无”,System.Text.RegularExpressions.Regex.Match(Fields!CourtLocation.Value,“(?:[A-Z]{2,4})”).Value))

主要目的是获取该子字符串,但我添加了IIF,以便在CourtLocation.Value为空的情况下(我也尝试了表达式中的Nothing),函数返回“none”而不是“Error”


我一直在四处寻找解决方案,但没有任何效果;似乎其他大多数谈论这个的人都在使用一个数学方程,而不是试图得到一个字符串。有谁能帮我去掉那个愚蠢的“#Error”值吗?

Iif对两边都求值,所以可以嵌套两个Iif语句来避免错误

你已经看过这个了吗?

如果答案对你有帮助,我会将文本复制到答案中。

你可以试试这个(未经测试)

=System.Text.RegularExpressions.Regex.Match(
IIF(
Len(Fields!CourtLocation.Value)<1,
“没有”,
字段!CourtLocation.Value
)
,“(?:[A-Z]{2,4})”
).价值

通过这种方式,
IIF
将在您想要传递给regex函数的字符串上执行,因此它始终会获得一个有效值来处理这个问题!只是为了克服IIF而改变顺序。。。我没有想到这些限制。谢谢我确实看到了这个问题,但很难应用它,因为我的问题不是数学问题。也许我遗漏了一些东西,本来可以做一些像这样的工作,但艾伦的解决方案很好地解决了我的问题。谢谢你的回复!
=System.Text.RegularExpressions.Regex.Match(
    IIF(
        Len(Fields!CourtLocation.Value) < 1,
        "none",
         Fields!CourtLocation.Value
        )
       , "(?:[A-Z]{2,4})"
      ).Value