字段表达式中的IIf返回错误ssrs2008

时间:2015-01-13 06:57:12

标签: ssrs-2008

我在ssrs字段表达式中有这个表达式:

iif(Sum(Fields!ActualWeight.Value)<>0 ,
Sum(Fields!ActualWeight.Value *Fields!AchievedPCN.Value)/Sum(Fields!ActualWeight.Value)
,0)

Sum(Fields!ActualWeight.Value) =0Sum(Fields!ActualWeight.Value *Fields!AchievedPCN.Value) =0返回#Error

为什么会这样?我的ssrs版本是2008年。

1 个答案:

答案 0 :(得分:0)

经过非常努力,我找到了解决方案:

=IIF((CInt(Sum(Fields!ActualWeight.Value))>0 
and CInt(Sum(Fields!ActualWeight.Value *Fields!AchievedPCN.Value))>0),
(Sum(Fields!ActualWeight.Value *Fields!AchievedPCN.Value))/iif(Sum(Fields!ActualWeight.Value)=0,1,Sum(Fields!ActualWeight.Value)),0)

我必须将它添加到Denominator:

iif(Sum(Fields!ActualWeight.Value)=0,1,Sum(Fields!ActualWeight.Value)

而不是

Sum(Fields!ActualWeight.Value)