Filtering as a New Expression

704
7
Jump to solution
07-06-2022 11:45 AM
ksost1
by
New Contributor

Hello I am super new to ArcGIS & Arcade, and I am hoping my ask is pretty simple... I just don't know what I am looking for to search. 

I have a list of zipcodes in the united states, and I was wondering if I can use the 'New Expression' to filter a number of zipcodes so that my graph will only show those? Sometimes the number will range from 50 zipcodes to 1,000. 

Is this possible and can the code as simple as: $feature["ZIP_CODE"] equals(10001, 10002)? 

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

If you have an explicit list of zip codes, the SQL version of that would be zipcode IN ('10001', '10002', '10004'...) but you don't have access to writing that filter in the web map. You could write it in Pro, or else modify the map's JSON using AGOL Assistant to paste the SQL in directly.

If that's too advanced, you can just keep modifying the existing filters. Try adding sets to the filter, so that you can combine "starts with 10" and "does not equal 10003" into a single condition.

Unfortunately, if you need a specific filter, you're going to need to do a lot of clicking. But there's really nothing stopping you from accomplishing this in the map.

- Josh Carlson
Kendall County GIS

View solution in original post

7 Replies
jcarlson
MVP Esteemed Contributor

Can you give some more information about where you're using this expression? Is it in a popup? A Dashboard?

Filtering your data to include multiple specific values is possible, but it's usually done outside of Arcade (though it is possible for an expression to do this, too).

- Josh Carlson
Kendall County GIS
0 Kudos
ksost1
by
New Contributor

Hi! thanks for reaching out. I am using a dashboard. My layer is all of the united states zipcodes. So for example, I only want to highlight around 2,000 specific zipcodes in New York.

After some research I saw I might have to create my file of those 2,000 zipcodes into a layer itself & combine the two.... I think I would rather hard code compared to that though because I am not having much luck that way either.

0 Kudos
jcarlson
MVP Esteemed Contributor

At the map level, you can apply a Filter.

jcarlson_0-1657141588750.png

 

From there, you can build an expression like this:

jcarlson_1-1657141704502.png

That way, the data is already filtered when the map loads in your Dashboard.

You can apply the same kind of filter in the Dashboard itself, but on a per-widget basis. Probably best to do it in the map.

- Josh Carlson
Kendall County GIS
ksost1
by
New Contributor

snipofmap.png

Thank you for the photos, super helpful. What if I only want to  show a specific portion of NY?

0 Kudos
jcarlson
MVP Esteemed Contributor

Play around with the filters and see! You should be able to get pretty close with some broad "begins with" filters, then some more specific ones to get anything else.

For instance, "starts with 10 Or starts with 11" gets you Manhattan and the southern end of the state. If you need more beyond that, you can just add more specific statements to the filter to get them.

jcarlson_0-1657202282197.png

 

- Josh Carlson
Kendall County GIS
0 Kudos
ksost1
by
New Contributor

Thank you so much for your help, although I would like a more specific way. I have ~2,000 unique zipcodes and it would be too much to play around with.

For example I might want to highlight zipcodes 10001,10002,10004...10013 but not 10003 

0 Kudos
jcarlson
MVP Esteemed Contributor

If you have an explicit list of zip codes, the SQL version of that would be zipcode IN ('10001', '10002', '10004'...) but you don't have access to writing that filter in the web map. You could write it in Pro, or else modify the map's JSON using AGOL Assistant to paste the SQL in directly.

If that's too advanced, you can just keep modifying the existing filters. Try adding sets to the filter, so that you can combine "starts with 10" and "does not equal 10003" into a single condition.

Unfortunately, if you need a specific filter, you're going to need to do a lot of clicking. But there's really nothing stopping you from accomplishing this in the map.

- Josh Carlson
Kendall County GIS