FMabey
asked on
#Error when using iif statement with divide by zero
Hi all,
I have an expression on a report as follows:
=iif(sum(Fields!EstHours.V alue) = 0,"N/A",sum(Fields!ACT_COM P_HRS.Valu e)/sum(Fie lds!EstHou rs.Value))
From time to time, the value of EstHours is zero. When this occurs, my expression returns a #Error as opposed to the N/A I require. I understand this is because the iif statement needs to evaluate the whole expression which includes the divide by zero. My question is, how do I remedy this?
Thanks in advance
I have an expression on a report as follows:
=iif(sum(Fields!EstHours.V
From time to time, the value of EstHours is zero. When this occurs, my expression returns a #Error as opposed to the N/A I require. I understand this is because the iif statement needs to evaluate the whole expression which includes the divide by zero. My question is, how do I remedy this?
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Nice.
Use
to avoid the error.
=iif(sum(Fields!EstHours.Value) = 0,1,sum(Fields!ACT_COMP_HRS.Value)/sum(Fields!EstHours.Value))
to avoid the error.
Does it?
no it doesn't, that will still result in Divide by zero...
ASKER
Thank you, this works just as required.