Sunday, 9 February 2014

SSRS: Trying to divide 0 by 0 and results end up as #Error?

Here is a trick that you can do. I need to sum two fields values and then divide it by another field value. What if the total of summation ends up with 0 and same time you are trying to divide it by 0. You can see the output as #Error.
 
What I have done here is I have checked whether the denominator is zero, if it is zero I have set it to 1 else use the normal field value. You can use this as a trick, using this trick you can customise according to your logical requirement.

 
=formatnumber(Sum(((Fields!hghra.Value + Fields!vghre.Value) / IIF(Fields!nmlhrs.Value=0,1,Fields!nmlhrs.Value))),2)

No comments:

Post a Comment