Answered by:
Boolean Expressions
Question

I have a unusual problem, well it is unusual becaue i cannot understand it.
I am retrieving the following data, Revenue, Sales, Commission, and calculating Commission Rate in the report itself.
I got warnings that a textbox that was attempting to calculate the Commission Rate was trying to divide by zero.
When I analysed the data, I realised that indeed there were instances when Revenue was 0.00 and therefore when calculating the commission rate, commission/revenue it returned an error.
I then thought I'd do the following in the expression field
=iif((Fields!RevenueGbp.Value = 0.00), "Zero", (Fields!Commission.ValueGbp/Fields!RevenueGbp.Value))
However this does not work. However if i tried the following Boolean query
=iif((Fields!RevenueGbp.Value = 0.00), "Zero", Fields!CommissionGbp.Value)
it does work. In fact if I use any other identifier or use two field thats add, subtract or multiplied with each other it will work. The problem only arises is when I decide to divide two fields together.
Strangely if the condition is satisfied  [Fields!RevenueGbp.Value = 0.00]  it will still try to work out the division even though it should just return Zero!
Anyone help?
Answers

hii
for more reference you can look into the below post
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2275977&SiteID=1
Thanks
Mahasweta
All replies

hii
Devide by Zero should be handled by using the expression as
Usage of expression =IIF(A=0,0,B/A) in Dataset fields gives Attempt to Divide by Zero Error
This was handled using this expression =IIF(A=0,0,B/IIF(A=0,1,A))
hope it will work fine
thanks
Mahasweta

hii
for more reference you can look into the below post
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2275977&SiteID=1
Thanks
Mahasweta
