How to combine an IF statement inside a for loop in Arcade ?

449
5
Jump to solution
06-30-2020 01:29 PM
KaramKhattab2
New Contributor II

Hello, 

I have an array of numbers (around 800 numbers) var mylist = [604703,607006,607606,607607,.................]

and I have a Number datatype field in one of my layers. I want to see if the data inside this field match any of the numbers in mylist? and when it does it will say for example " Matched " if does not " No Match".

Thank you. 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Honored Contributor

You can use IndexOf to determine whether an item is found in array

if (IndexOf(myList, feature.$Number) > -1){
return "Matched";
} else {
return "No Match";
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

5 Replies
KenBuja
MVP Honored Contributor

You can use IndexOf to determine whether an item is found in array

if (IndexOf(myList, feature.$Number) > -1){
return "Matched";
} else {
return "No Match";
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

View solution in original post

KaramKhattab2
New Contributor II

Thank you so much @ken buja ! it worked !!   I was able to use it in the configure popups and in symbology expressions !

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Not that this is any better than Ken's answer, just a slightly different code structure:

IIf(IndexOf(myList,feature.$Number) > -1, "Matched", "No Match");
KaramKhattab2
New Contributor II

Thank you @Joshua Bixby ! It worked ! 

0 Kudos
KaramKhattab2
New Contributor II

Both @ ken Buja and Joshua bixby's code worked with me !!!

0 Kudos