Null field problem in calculated field

  • I have the following expression:

    =iif(isnothing(reportitems.textbox1.value),1,2) which works fine, however when I switch the false statement to,... reportitems.textbox2.value/reportitems.textbox1.value to read:

    =iif(isnothing(reportitems.textbox1.value),1,reportitems.textbox2.value/reportitems.textbox1.value) it seems to ignore the isnothing part and I get #error.

    Any ideas why this is?

    Thanks

    Carl.

  • Yes, that's one big PITA with SSRS. The WHOLE expression gets evaluated. So it still divides by 0 even if you use an iff.

    You need something like this in your code section :

    PUBLIC FUNCTION NDZ(Numerator, Denominator, DZResult)

    IF Denominator = 0 THEN

    RETURN DZResult

    ELSE

    RETURN Numerator / Denominator

    END IF

    END FUNCTION

    Then to call the function :

    =code.NDZ(Value1, Value2, 0)

  • Thats genius, thanks so much!

  • HTH, I wish we didn't need this ;-).

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply