Arcade Expression Calculations NaN values

2122
5
04-03-2020 10:42 AM
JasonSimpson
New Contributor III

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.  

0 Kudos
5 Replies
KenBuja
MVP Esteemed Contributor

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) + "%")
JasonSimpson
New Contributor III

Worked perfectly. Thanks for the speedy response. 

0 Kudos
KenBuja
MVP Esteemed Contributor

Glad to help! Don't forget to click the Mark Correct button

0 Kudos
XanderBakker
Esri Esteemed Contributor

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. 

0 Kudos
KenBuja
MVP Esteemed Contributor

You're correct, Xander Bakker that should just be

$feature["Field2"] == 0