Select to view content in your preferred language

Can't identify where to close parenthesis? Arcade Field Calc

856
3
Jump to solution
11-14-2023 10:22 AM
Amarz
by
Frequent Contributor

I am getting the error

'Invalid expression.
Error on line 2.
Close parenthesis expected'

that I can't seem to figure out. This is a fairly straight forward expression asking if the contents of field LP1 = [a,b,c,d] return 'Yes' else return null. Can you help me identify its error?

var owned = ['a','b','c','d'];
var v = iif($feature.LP1 in owned,"Yes", null);
return v;

Thanks for the help.. 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

Are you trying to see if LP1 contains one of those four values or the array "['a','b','c','d']"?

If you're checking if it contains one of those values, then you'll use the Includes function in your iif.

var owned = ['a','b','c','d'];
var v = iif(Includes(owned, $feature.LP1),"Yes", null);
return v;

 

View solution in original post

0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor

Are you trying to see if LP1 contains one of those four values or the array "['a','b','c','d']"?

If you're checking if it contains one of those values, then you'll use the Includes function in your iif.

var owned = ['a','b','c','d'];
var v = iif(Includes(owned, $feature.LP1),"Yes", null);
return v;

 

0 Kudos
Amarz
by
Frequent Contributor

Thanks @KenBuja, my 'Include' was in the wrong position and syntax.

0 Kudos
DavidPike
MVP Frequent Contributor
var owned = ['a','b','c','d'];
var v = iif(Includes(owned, $feature.LP1),"Yes", null);
return v;
0 Kudos