我在报告中使用了以下表达式
=IIF((Sum(Fields!Starts.Value)-Sum(Fields!Withdrawn.Value))=0, Nothing,
(Sum(Fields!Starts.Value)-Sum(Fields!Withdrawn.Value))/(Max(Fields!Year1Starts.Value)))
当我运行报告时,我收到消息并显示为#Error
Warning 1 [rsRuntimeErrorInExpression]
The Value expression for the textrun ‘Textbox110.Paragraphs[0].TextRuns[0]’ contains an error:
Attempted to divide by zero.
我尝试了这个但得到同样的错误:
=IIF((Sum(Fields!Starts.Value) - Sum(Fields!Withdrawn.Value)) = 0, Nothing,
(Sum(Fields!Starts.Value) - Sum(Fields!Withdrawn.Value))/
IIF(Max(Fields!Year1Starts.Value)=0,1,Max(Fields!Year1Starts.Value)))
有人可以帮忙吗?
阿鲁娜
答案 0 :(得分:1)
你必须处理除数并防止它作为值得到0。类似的东西:
=IIf(Fields!SomeField.Value = 0, 0, Fields!SomeOtherField.Value / IIf(Fields!SomeField.Value = 0, 1, Fields!SomeField.Value))
这将在除数中用1替换0,从而避免此错误。
答案 1 :(得分:1)
我试过这个并且有效:
=IIF(Max(Fields!Year1Starts.Value)=0,0,(Sum(Fields!Starts.Value)
- Sum(Fields!Withdrawn.Value))/IIF(Max(Fields!Year1Starts.Value)=0,1,
Max(Fields!Year1Starts.Value)))
我跟着这个:
=IIF ( Denominator = 0, Nothing, Numerator / IIF( Denominator = 0, 1, Denominator) )