September 13, 2011 at 5:28 am
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.
September 13, 2011 at 5:34 am
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)
September 13, 2011 at 6:24 am
Thats genius, thanks so much!
September 13, 2011 at 6:33 am
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