I have Productivity calculation as TotalMinutes/(TotalHours*60) Some of my TotalHours values=0 and I need to exclude them from calculation.
How do I write it in Field Expression window?
My current expression is (I am also setting zeros to "99" values in this field):
=IIf(Fields!TotalHours.Value=0,99,
Sum(Fields!TotalMinutes.Value/(Fields!TotalHours.Value*60)))
Thank you for help
This is untested but should work...
The problem is that IIF will evaluate both expressions even if one is never used so to avoid a divide by zero we need to swap the potential zero for a 1. This won't affect the result as it will never be used as the final output.
So what happens here is that if TotalHours is zero we do a 0/1 in the False part of the outer IIF just to satisfy the IIF statement (it will never actually be used)