I have an Arcade expression for a When() logical for Field Calculator. I am calculating string field based on the values of a numeric field. However, I keep getting the error
"Invalid expression. Error on line 1. Semicolon or new line expected" I cannot figure out why it is not recognizing the semi colon after I identified the numeric field as a variable.
var $feature.percent;
When(percent = 0, 'Not Hydric', percent > 0 && percent <50, 'Non-Hydric with Hydric Inclusions', percent >= 50 && percent < 100, 'Predominantly Hydric', percent = 100, 'Hydric', 'N/A');
Any help is appreciated.
Solved! Go to Solution.
Hi @CamTurney ,
You will need to declare your variable like so:
var percent = $feature.percent;
You can find more info about declaring variables in the documentation here.
For the comparison operators in your When() statement, you will also need to use == to indicate 'equal to'. In your example you only use =.
So the expression should look something like this:
var percent = $feature.percent;
When(percent == 0, 'Not Hydric', percent > 0 && percent <50, 'Non-Hydric with Hydric Inclusions', percent >= 50 && percent < 100, 'Predominantly Hydric', percent == 100, 'Hydric', 'N/A');
Hi @CamTurney ,
You will need to declare your variable like so:
var percent = $feature.percent;
You can find more info about declaring variables in the documentation here.
For the comparison operators in your When() statement, you will also need to use == to indicate 'equal to'. In your example you only use =.
So the expression should look something like this:
var percent = $feature.percent;
When(percent == 0, 'Not Hydric', percent > 0 && percent <50, 'Non-Hydric with Hydric Inclusions', percent >= 50 && percent < 100, 'Predominantly Hydric', percent == 100, 'Hydric', 'N/A');
This solved my problem, Thanks!!