Answered by:
Divide by zero not working

Hi,
I have two rows, one for detail numbers and one row above like group , where are totals. I have two columns Sell in year N and Sell in year N minus 1. Numbers are grouped on week level.
I want to make division of those numbers (sense of number is not important now) at the group level = division of sums of those numbers.
If I do my expression without division operation, then its working perfectly
=IIF(IsNothing(SUM(Fields!SellNMinus1.Value)) or SUM(Fields!SellNMinus1.Value)=0,"Do not divide", "Divide")
After report is generated then I really see "Do not divide" for all weeks, where SellNMinus1 is 0 or null.
If I exchange expression by
=IIF(IsNothing(SUM(Fields!SellNMinus1.Value)) or SUM(Fields!SellNMinus1.Value)=0,"Do not divide",
SUM(Fields!SellN.Value)/SUM(Fields!SellNMinus1.Value))Then it shows #Error in fields, where SellNMinus1 is 0 or null and in BIDS I see message
Warning 1 [rsRuntimeErrorInExpression] The Value expression for the textrun ‘Textbox4.Paragraphs[0].TextRuns[0]’ contains an error: Attempted to divide by zero. F:\Ewals\Lori reports 2013\Lori reports 2013\NEWBranch results.rdl
I am lost, whats wrong ?
thanks
Question
Answers

Hi,
Try this link . I hope it will help you !!
sathya  www.allaboutmssql.com ** Mark as answered if my post solved your problem and Vote as helpful if my post was useful **.
 Proposed as answer by Alisa TangMicrosoft contingent staff, Moderator Monday, October 28, 2013 2:51 AM
 Marked as answer by Alisa TangMicrosoft contingent staff, Moderator Friday, November 01, 2013 10:21 AM

=IIF(IsNothing(SUM(Fields!SellNMinus1.Value)) or SUM(Fields!SellNMinus1.Value)=0,"Do not divide", IIF(IsNothing(SUM(Fields!SellNMinus1.Value)) or SUM(Fields!SellNMinus1.Value)=0,Nothing, Cstr(SUM(Fields!SellN.Value)/SUM(Fields!SellNMinus1.Value))))
 Marked as answer by Alisa TangMicrosoft contingent staff, Moderator Friday, November 01, 2013 10:23 AM
All replies

Hi,
Try this link . I hope it will help you !!
sathya  www.allaboutmssql.com ** Mark as answered if my post solved your problem and Vote as helpful if my post was useful **.
 Proposed as answer by Alisa TangMicrosoft contingent staff, Moderator Monday, October 28, 2013 2:51 AM
 Marked as answer by Alisa TangMicrosoft contingent staff, Moderator Friday, November 01, 2013 10:21 AM

=IIF(IsNothing(SUM(Fields!SellNMinus1.Value)) or SUM(Fields!SellNMinus1.Value)=0,"Do not divide", IIF(IsNothing(SUM(Fields!SellNMinus1.Value)) or SUM(Fields!SellNMinus1.Value)=0,Nothing, Cstr(SUM(Fields!SellN.Value)/SUM(Fields!SellNMinus1.Value))))
 Marked as answer by Alisa TangMicrosoft contingent staff, Moderator Friday, November 01, 2013 10:23 AM