expression help
I am trying to write an expression to show total margin, if the totalRevenue =0 then i want it to display 0 (b/c i get an divide by 0 error) and if its not 0 i want it to subtract 2 fields and divide by revenue (Fields!totalRevenue.Value-Fields!totalRepairCost.Value)/Fields!totalRevenue.Value) This was my best shot at it, but it is not right =Iif (Fields!totalRevenue.Value= 0, "0", Iif(Fields!totalRevenue.Value>=1, (Fields!totalRevenue.Value-Fields!totalRepairCost.Value)/Fields!totalRevenue.Value)
June 9th, 2011 3:19pm

Hi SBolton, Please check your IIF syntax, you should have IIF ( <condition>, True, False ). I don't see "False" part for the nested IIF statement. Please double your expression properly. Also, I would recommend you to check only first your nested IIF statement if everything is coming as per your req. than you can check with nested IIF Statements than you can troubleshoot, this will make your troubleshoot process easier. Thanks KumarKG, MCTS
Free Windows Admin Tool Kit Click here and download it now
June 9th, 2011 3:53pm

The false part of the condition should do the calculation, so if its not 0 (false ) this still throws an error when dividing by zero =iif(Fields!Line_Amount.Value=0,0,(Fields!Line_Amount.Value-Fields!RunCost.Value)/Fields!Line_Amount.Value)
June 9th, 2011 4:07pm

http://codemonkeyjas.blogspot.com/2008/03/sql-reporting-services-dividing-by-zero.html =code.SafeDivide(Fields!Line_Amount.Value-Fields!RunCost.Value,Fields!Line_Amount.Value)
Free Windows Admin Tool Kit Click here and download it now
June 9th, 2011 4:32pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics