为什么在我的SSRS报告中没有将空值转换为零

时间:2018-05-10 11:05:39

标签: reporting-services

我有以下表达式:

=IIF(IsNothing(Fields!WellTestMeasLiqRate.Value) = true, 
     CDec(0), 
     IIf(Fields!WellTestMeasLiqRate.Value > 0,
         Fields!WellTestTotalGasRate.Value / Fields!WellTestMeasLiqRate.Value, 
         CDec(0)))

但是,IsNothing子句似乎没有捕获空值,因此当我生成报告时,此字段返回#VALUE。

任何指针都将不胜感激!

2 个答案:

答案 0 :(得分:0)

这样的错误,与SSRS表达式评估有关。

使用以下表达式:

echo $fileprefix
filename
echo $filesuffix
.txt.zip

enter image description here

答案 1 :(得分:0)

SSRS验证IFF表达式的两面。因此,如果分母为0,无论你检查多少次都会给你#error。

您需要做的是在报告属性代码窗口中放置一个小函数

Public Function divide(Byval a As Decimal,Byval b As Decimal, Byval c As Decimal) As Decimal
'  Fix for divide by zero problem in VB
' calculates  a/b  and either returns result or c if b = 0 


if b = 0 then 
    return c 
else 
    return a/b 
end if 

end function 

然后使用此代码进行划分

这就是你调用代码的方式

=code.divide(fields!numerator.value,Fields!denominator.Value,0.0)