# Divide by zero not working

### Question

• 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

Saturday, October 26, 2013 12:05 PM

### 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 **.

Saturday, October 26, 2013 1:56 PM
• ```=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))))```

Saturday, October 26, 2013 6:36 PM

### 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 **.

Saturday, October 26, 2013 1:56 PM
• ```=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))))```

Saturday, October 26, 2013 6:36 PM