DataColum.Expression (IIF Function Bug)

  • Thread starter Thread starter Paul Say
  • Start date Start date
P

Paul Say

I am trying to prevent the following error
System.DivideByZeroException: Attempted to divide by zero.

When populating a calculated field. I tried using the IIF() function,
however this was no help as the function attempts to calculate both the true
and false return values before doing the IF test (A bug with this function I
believe)

objColumn.Expression =
"IIF([Original_Contract_Amount]>0,([Original_Contract_Amount] -
[Original_Estimate])/([Original_Contract_Amount]),0)"

Just wondering if anyone any sugesstions for a work arround.


Thanks Paul
 
the problem is no "shortcut logic". I guess the solution could be like:
IIF([OCA]>0,([OCA] - OE])/(IIF([OCA]>0,OCA,1)),0)
 
Thankyou

I came up with the same solution, and it works fine.


Uri Dor said:
the problem is no "shortcut logic". I guess the solution could be like:
IIF([OCA]>0,([OCA] - OE])/(IIF([OCA]>0,OCA,1)),0)

Paul said:
I am trying to prevent the following error
System.DivideByZeroException: Attempted to divide by zero.

When populating a calculated field. I tried using the IIF() function,
however this was no help as the function attempts to calculate both the true
and false return values before doing the IF test (A bug with this function I
believe)

objColumn.Expression =
"IIF([Original_Contract_Amount]>0,([Original_Contract_Amount] -
[Original_Estimate])/([Original_Contract_Amount]),0)"

Just wondering if anyone any sugesstions for a work arround.


Thanks Paul
 
Back
Top