Groups | Blog | Home
all groups > sql server reporting services > november 2005 >

sql server reporting services : Divide by Zero error


David
11/17/2005 12:41:05 PM
I am still getting this error. This is my formula:
=iif(ReportItems!BUDMTD_2.Value=0,0,ReportItems!MTDChange_2.value/ReportItems!BUDMTD_2.Value)

Lev Semenets [MSFT]
11/18/2005 12:51:20 AM
IIF is a function call. Therefore all arguments get evaluated before IIF is
called and you see a division by zero.
Possible solutions can be:
1) Avoid 0 in divisor (consider
=iif(ReportItems!BUDMTD_2.Value=0,0,ReportItems!MTDChange_2.value /
iif(ReportItems!BUDMTD_2.Value = 0, 1,ReportItems!BUDMTD_2.Value ))
2) Write VB function SafeDivide (A,B) and call it when needed (search
"SafeDivide" in this group)

--
This posting is provided "AS IS" with no warranties, and confers no rights.


[quoted text, click to view]

Peter Nolan
11/18/2005 7:12:09 AM
David,
just in case it helps....I got so tired of writing statements like this
and trying to test them (because you finish up writing a lot of them)
that I wrote my division routines into a custom assembly and called the
custom assembly...the custom assembly then gives me much more control
over how I deal with bad data in calculations...

Peter
www.peternolan.com
AddThis Social Bookmark Button