Sunday, March 11, 2012

Division by zero

Hi, I have a field in which I use a division. Sometimes the denominator can
be zero. In such case, I want to return 0 instead of evaluating the division
giving me an error.
Here is what I attempted but without success. It appears that both
expressions are evaluated all the time regardless of the result of the
condition.
=iif( Fields!Denominator.Value = 0, 0, Fields!Numerator.Value/
Fields!Denominator.Value)
I would like to know if someone knows a work around to this.
Thanks,
JoeI finally found a way to do it:
=((Fields!Numerator.Value / iif( Fields!Denominator.Value = 0, 1,
Fields!Denominator.Value)) * iif( Fields!Denominator.Value = 0, 0, 1))|||Thats the way I was doing it. But if you have a bunch of these its
gets tedious and I would recommend writing a custom assembly that does
this instead.
Abe
joerage wrote:
> I finally found a way to do it:
> =((Fields!Numerator.Value / iif( Fields!Denominator.Value = 0, 1,
> Fields!Denominator.Value)) * iif( Fields!Denominator.Value = 0, 0,
1))

No comments:

Post a Comment