I am in the process of creating a field calculation through expression for a popup and keep getting a return of NaN for records that have a zero dollar value in both fields. My expression is as followed.
Round(($feature["Field1"]/$feature["Field2"])*100,2) + "%"
Is it possible to create return text for all fields that have NaN as the value? I have created return values for fields with null values before, but I am uncertain if fields with NaN is possible. Thanks.
You could wrap this in an iif to check if the value is zero.
IIf($feature["Field2"] === 0, "Zero", Round(($feature["Field1"]/$feature["Field2"])*100,2) + "%")
Worked perfectly. Thanks for the speedy response.
Glad to help! Don't forget to click the Mark Correct button
Hi Jason Simpson and Ken Buja ,
Question... does this work? I am getting this error message:
Parse Error:Syntax Error: Binary Operator not recognised ===
... when using 3 equal signs "===".
And do you have 0 values or is the field empty (null)? If so you may need to change the expression.
You're correct, Xander Bakker that should just be
$feature["Field2"] == 0