Answered by:
Divide by Zero Error
Question

Hi,
I have written an expression and i am taking care of the Divde by Zero condition... but still getting that error...
Can someone please take a look at my expression and let me know what is wrong..
=(IIF(isnothing((sum(Fields!totbudamt.Value)  ((Sum(Fields!amt.Value)/2 + ((Sum(Fields!amt.Value)/2)/3)* Fields!IBNRFact.Value) * Parameters!AnnualFact.Value)) / IIF(isnothing(Fields!totbudamt.Value),0,sum(fields!totbudamt.Value))),0,(sum(Fields!totbudamt.Value)  ((Sum(Fields!amt.Value)/2 + ((Sum(Fields!amt.Value)/2)/3)* Fields!IBNRFact.Value) * Parameters!AnnualFact.Value)) / IIF(sum(Fields!totbudamt.Value)= 0,1,sum(fields!totbudamt.Value))))
Thanks,
KArenThursday, September 17, 2009 7:13 PM
Answers


Karen,
By looking at the expression, I'm assuming that totbudamt is a money or decimal or float type datatype. Hence, you can't do comparison with "0.00" as this will assume it's a string. Try revising them to this:
=IIf(isnothing(sum((
IIF(Fields!totbudamt.Value=0.00,cdbl(0),cdbl(fields!totbudamt.Value))))  ((Sum(Fields!amt.Value)/2 + (((Sum(Fields!amt.Value)/2)/3) * Fields!IBNRFact.Value))* Parameters!AnnualFact.Value)) / Sum((
IIF(Fields!totbudamt.Value = 0.00,cdbl(0),cdbl(fields!totbudamt.Value)))),cdbl(0),sum((
IIF(Fields!totbudamt.Value=0.00,cdbl(0),cdbl(fields!totbudamt.Value))))  ((Sum(Fields!amt.Value)/2 + (((Sum(Fields!amt.Value)/2)/3) * Fields!IBNRFact.Value))* Parameters!AnnualFact.Value)) /
IIf((Sum((IIF(Fields!totbudamt.Value = 0.00,cdbl(0),cdbl(fields!totbudamt.Value)))))=0.00,cdbl(1),(Sum((
IIF(Fields!totbudamt.Value = 0.00,cdbl(0),cdbl(fields!totbudamt.Value))))))
Hopefully this will works (it's a long expression)
Chicagoan ... Marked as answer by Karenros Friday, September 18, 2009 2:25 PM
Friday, September 18, 2009 2:16 PMAnswerer
All replies


I got rid of the Divide by Zero Error
But now i am getting #error where there should be data
and this is my expression=IIf(isnothing(sum(( IIF(Fields!totbudamt.Value="0.00",0,fields!totbudamt.Value)))  ((Sum(Fields!amt.Value)/2 + (((Sum(Fields!amt.Value)/2)/3) * Fields!IBNRFact.Value))* Parameters!AnnualFact.Value)) / Sum(( IIF(Fields!totbudamt.Value = "0.00",0,fields!totbudamt.Value))),0,sum(( IIF(Fields!totbudamt.Value="0.00",0,fields!totbudamt.Value)))  ((Sum(Fields!amt.Value)/2 + (((Sum(Fields!amt.Value)/2)/3) * Fields!IBNRFact.Value))* Parameters!AnnualFact.Value)) / IIf((Sum((IIF(Fields!totbudamt.Value = "0.00",0,fields!totbudamt.Value)))) =0,1,(Sum(( IIF(Fields!totbudamt.Value = "0.00",0,fields!totbudamt.Value)))))
Please help!!Friday, September 18, 2009 1:58 PM 
Karen,
By looking at the expression, I'm assuming that totbudamt is a money or decimal or float type datatype. Hence, you can't do comparison with "0.00" as this will assume it's a string. Try revising them to this:
=IIf(isnothing(sum((
IIF(Fields!totbudamt.Value=0.00,cdbl(0),cdbl(fields!totbudamt.Value))))  ((Sum(Fields!amt.Value)/2 + (((Sum(Fields!amt.Value)/2)/3) * Fields!IBNRFact.Value))* Parameters!AnnualFact.Value)) / Sum((
IIF(Fields!totbudamt.Value = 0.00,cdbl(0),cdbl(fields!totbudamt.Value)))),cdbl(0),sum((
IIF(Fields!totbudamt.Value=0.00,cdbl(0),cdbl(fields!totbudamt.Value))))  ((Sum(Fields!amt.Value)/2 + (((Sum(Fields!amt.Value)/2)/3) * Fields!IBNRFact.Value))* Parameters!AnnualFact.Value)) /
IIf((Sum((IIF(Fields!totbudamt.Value = 0.00,cdbl(0),cdbl(fields!totbudamt.Value)))))=0.00,cdbl(1),(Sum((
IIF(Fields!totbudamt.Value = 0.00,cdbl(0),cdbl(fields!totbudamt.Value))))))
Hopefully this will works (it's a long expression)
Chicagoan ... Marked as answer by Karenros Friday, September 18, 2009 2:25 PM
Friday, September 18, 2009 2:16 PMAnswerer 
Isham,
Thanks a lot for the answer... and you were correct totbudamt is money datatype and your expression worked perfectly...
I couldnt think what else to do with this expression and was working on this for 2 days...
Thanks,
KarenFriday, September 18, 2009 2:25 PM