Select to view content in your preferred language

Arcade expression for displaying only selected features

1405
1
Jump to solution
05-21-2021 10:04 AM
Labels (1)
KhemAryal
New Contributor III

I have a map displaying over 4000 features, each with unique IDs. Out of these 4000 features, I need to display only 250 features with selected unique IDs. Is there a short  formula to display only those 250 features. 

List of features id :

1964004

1444000

1719002

1452034

1618000

1602002

2004000

1175000

2012000

1172002

1946000

continues to 250 ids

 

Expression I used:

var mh = $feature.UNITID;

if ((mh=="1964004")||(mh=="1444000")||(mh=="1719002")||(mh=="1452034")||(mh=="1618000")||(mh=="1602002")||(mh=="2004000")||(mh=="1175000")||(mh=="2012000")||(mh=="1172002")||(mh=="1946000")){
return"selected";
} else {
return"";
}

This works as intended but I am wondering if there is a short expression where I can just copy the list rather than typing each features in the bracket

Thanks

KA

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Hi @KhemAryal I would recommend using Includes(), an array method added at a recent Arcade release. 

var mh = $feature.UNITID;
var arr = [4, 7, 8, 900, 23, 4]; // these would be your 250 IDs 
if (Includes(arr, mh)) {
    return "selected"
} else {
    return ""
}

 

View solution in original post

1 Reply
by Anonymous User
Not applicable

Hi @KhemAryal I would recommend using Includes(), an array method added at a recent Arcade release. 

var mh = $feature.UNITID;
var arr = [4, 7, 8, 900, 23, 4]; // these would be your 250 IDs 
if (Includes(arr, mh)) {
    return "selected"
} else {
    return ""
}