Select to view content in your preferred language

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

1429
5
Jump to solution
06-30-2020 01:29 PM
by Anonymous User
Not applicable

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 Esteemed 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 Esteemed 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";
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
by Anonymous User
Not applicable

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");
by Anonymous User
Not applicable

Thank you @Joshua Bixby ! It worked ! 

0 Kudos
by Anonymous User
Not applicable

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

0 Kudos