May 27, 2008 at 11:49 am
Hi All,
I have to calculate CPH SPH Wrap% which involves other fields in my report. But in rare cases my Dialling Time calculated is just a few seconds, which when i turn into a decimal (DECIMAL(6,2)) is less than 0.00. The expression below should work but what get is #Error. What Am I doing wrong. Thank you in advance.
=IIF(Sum(Fields!Contacts.Value)=0,0.00,IIF(Sum(Fields!DiallingTime.Value)<=0.00,0.00,(Sum(Fields!Contacts.Value)/Sum(Fields!DiallingTime.Value))))
June 23, 2008 at 3:29 pm
=IIF(Sum(Fields!Contacts.Value)=0,0.00,IIF(Sum(Fields!DiallingTime.Value)<=0.00,0.00,(Sum(Fields!Contacts.Value)/Sum(Fields!DiallingTime.Value))))
The odd thing about SSRS is that it really doesn't allow you to cope with division by zero errors within the expression, I have often tried to use the same code as above but without success.
The way I do this is to create a function for divisons and then call the function in the expression.
1. Create the function (do this by going to the report properties, go to custom code tab) - the function should be:
FUNCTION DivZero(Value1 as Double, Value2 as Double) AS Double
IF Value2 = 0 THEN Return 0
Return(Value1/Value2)
END FUNCTION
2. Replace your code above with the following
=CODE.DivZero(Sum(Fields!Contacts.Value),Sum(Fields!DiallingTime.Value)
This should help to overcome the problem.
Nigel West
UK
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply