Arcade syntax question: checking if value is in a list

957
2
Jump to solution
08-17-2020 06:57 AM
Katie_Clark
MVP Regular Contributor

Hello,

I am hoping this is a fairly simple question but I'm just a bit unclear on the syntax for Arcade and haven't been able to find the answer I need.

I want to return a certain value based on whether the county name is in a predefined list or not.

Something like this:

var counties = ['County1', 'County2']
if ( $feature.NAME IN counties ) {
return "Processed"
}
else {
return "Not Processed"
}

Thanks in advance for any guidance!

Cheers,

KC

Best,
Katie


“The goal is not simply to ‘work hard, play hard.’ The goal is to make our work and our play indistinguishable.”
- Simon Sinek
0 Kudos
1 Solution

Accepted Solutions
JoshuaSharp-Heward
Occasional Contributor III

Not sure if this is the offical way of doing this but if you use indexOf(list, value) and the value isn't in the list it returns a -1, so you can set up a little switch using it! See below:

var counties = ['County1', 'County2']

IIF(indexOf(counties, $feature.NAME) != -1, "Processed", "Not Processed")‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

2 Replies
JoshuaSharp-Heward
Occasional Contributor III

Not sure if this is the offical way of doing this but if you use indexOf(list, value) and the value isn't in the list it returns a -1, so you can set up a little switch using it! See below:

var counties = ['County1', 'County2']

IIF(indexOf(counties, $feature.NAME) != -1, "Processed", "Not Processed")‍‍‍‍‍‍‍‍‍‍‍‍
Katie_Clark
MVP Regular Contributor

Thanks for the quick reply! That works!

Best,
Katie


“The goal is not simply to ‘work hard, play hard.’ The goal is to make our work and our play indistinguishable.”
- Simon Sinek