문제

This is my statement:

iif(sum(Fields!myfield1.Value) = 0, 0, sum(Fields!myField2.Value)/sum(Fields!myField1.Value))

Any suggestions?

도움이 되었습니까?

해결책

Likely it is evaluating as True. As mentioned in other comments, you'll get an error anyway because Iif() evaluates all parameter expressions regardless of the result of the test.

The error can be avoided by adding another Iif() in the divisor.

iif(
    sum(Fields!myfield1.Value) = 0,
    0,
    sum(Fields!myField2.Value) / iif(
                                     sum(Fields!myfield1.Value) = 0,
                                     1,
                                     sum(Fields!myField1.Value)
                                 )
)

Now you'll get zero if myfield1 is zero and no error is thrown.

(You probably should show 'N/A' or just an empty string when the divisor is zero, though.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top