Select to view content in your preferred language

Can't Get Arcade to Recognize a New Line

363
2
Jump to solution
03-04-2025 09:03 AM
CamTurney
Emerging Contributor

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. 

0 Kudos
1 Solution

Accepted Solutions
timcneil
Esri Contributor

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');

 

View solution in original post

2 Replies
timcneil
Esri Contributor

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');

 

CamTurney
Emerging Contributor

This solved my problem, Thanks!!

0 Kudos