I have an IIF that looks like it is evaluating the full equation instead of acting on the first 'TRUE' part of the statement.
I have the following code in a cell on a report.
If their are NoTurns of Inventory, place a zero in the box. (Currently it shows ERR# when the value is zero).
And if there ARE NoTurns in Inventory, do the math calculation... which it does fine...
What am I missing??
This is the code I am using... I split it out to 4 lines just so I could visualize the layout/condition.
CODE START
=IIF( SUM(Fields!NoOfTurns.Value) = 0
, 0
, ((Sum(Fields!Item__Sales__Qty___.Value) + Sum(Fields!Item__Negative_Adjmt___Qty___.Value)) / Sum(Fields!AverageInventory.Value))
)
CODE END
I have tried using SWITCH, same issue. "=SWITCH(sum(Fields!NoOfTurns.Value) = 0, 0, sum(fields!NoOfTurns.Value > 0, *above equation*)
Shouldn't be rocket science to say "If your zero, print a zero"...
Any insight on how to fix this would be greatly appreciated... hate having a report show ERROR when I nice zero will do...
ADS
Answers
Please try with
=IIF(SUM(Fields!NoOfTurns.Value)=0,0,IIF(SUM(Fields!AverageInventory.Value)<>0,((SUM(Fields!Item__Sales__Qty___.Value) + SUM(Fields!Item__Negative_Adjmt___Qty___.Value)) /SUM(Fields!AverageInventory.Value)),0)). I checked it with some other variables and it worked fine.
Its the same thing I get...
when there is inventory, I (and you) get a value... but when its zero... the ERR is present.
I put your formula in a new cell... 'high lighted in pic'
https://community.dynamics.com/nav/b/navisiontechnicalkulla/archive/2015/10/24/how-to-resolve-divide-by-zero-error-in-navision-rtc-report
Thanks for helping me to learn
who would have thought that RTC evaluates all the formulas first... then decides which to use...what a nightmare...
and THANK YOU... for helping me learn!!!!