December 5, 2008 at 9:57 am
I have this expression in a report : =IIF(CINT(SUM(Fields!QteFacture.Value)) = 0, -1, SUM(Fields!MontantFacture.Value) / SUM(Fields!QteFacture.Value))
half the time, the -1 value shows up, and the other half I get a divide by 0 error.
anyone can shed some light on this?
December 5, 2008 at 2:22 pm
Ninja's_RGR'us (12/5/2008)
I have this expression in a report : =IIF(CINT(SUM(Fields!QteFacture.Value)) = 0, -1, SUM(Fields!MontantFacture.Value) / SUM(Fields!QteFacture.Value))half the time, the -1 value shows up, and the other half I get a divide by 0 error.
anyone can shed some light on this?
I don't think SSRS' VB implementation will optimize that statement to avoid the divide by zero. Try this.
= iif( SUM(Fields!QteFacture.Value) = 0, -1,
SUM(Fields!MontantFacture.Value) /
iif( SUM(Fields!QteFacture.Value) = 0, 1, SUM(Fields!QteFacture.Value)))
BTW, this is just another example of how dumb it was for MS to provide VB as the only scripting language for SSRS 2005.
December 5, 2008 at 3:05 pm
Thanx for the reply... the weird thing is that half the time it works (when there's no data to display, the iff works, but when the amount is 0, it fails (constantly). I've also tried < 1 in case of rounding issues but that didn't work either.
I'll let you know how it goes once Ican test it (out of office right now).
December 8, 2008 at 6:03 am
Yup, that solution solved my problem, thanx for the help.
Now I have more respect for ms access... that iif works in there ;).
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply