Can you use an Arcade field in a hosted layer's filter?

1059
5
Jump to solution
12-06-2019 01:56 PM
SteveCole
Frequent Contributor

Working in Portal and have a hosted layer that has an integer field which represents a given calendar year.I recently realized there are some features where the value in this field represent previous years so I want to exclude them from my map using a filter. Arcade generated fields are recognized in both the symbology and pop up dialogs but they are not visible in the layer's filter dialog.

This is the case? Are you not able to utilize an Arcade calculated field within the filter dialog? To be perfectly clear, this is the dialog I'm referring to:

Thanks!

Steve

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi Steve Cole ,

I hate to tell you, but at this moment you cannot use arcade "virtual fields" in a filter expression. It would be nice to have and users have be asking for the functionality: https://community.esri.com/ideas/15619 

View solution in original post

0 Kudos
5 Replies
XanderBakker
Esri Esteemed Contributor

Hi Steve Cole ,

I hate to tell you, but at this moment you cannot use arcade "virtual fields" in a filter expression. It would be nice to have and users have be asking for the functionality: https://community.esri.com/ideas/15619 

0 Kudos
SteveCole
Frequent Contributor

Ok, yeah, that would be ideal. I think I'll be able to handle my current situation using the trick of using AGO Assistant to tweak the underlying SQL query string.

Thanks-

Steve

DanteLee
Occasional Contributor II

Were you successful in tweaking the query in AGO Assistant? If so, pointers?

0 Kudos
SteveCole
Frequent Contributor

Dante-

Yes, it was fairly straightforward. Open up AGO Assistant and then navigate to your webmap of interest and chose "View an items JSON" from the "I Want to..." menu. The second "block" of JSON code details with the layers in the webmap. Scroll through it until you find the layer you need to tweak. Once you find the layer, you'll want to zero in on the DefinitionExpression property. Here's what it looks like in my edited webmap:

The later half of the definitionExpression sets the criteria for a date between the current year and 12 years from now. The above expression is based on an actual date field but you could also do the same thing with a text based field as well. Originally, the data I was provided had the 4 digit year stored as text. Here's the same definition but for a text based field:

"((M8UpgradeBy = 'Transition Plan') OR (M8UpgradeBy = 'Capital Project') OR (M8UpgradeBy = 'Overlay Program')) AND (m9upgradeyr >= EXTRACT(YEAR FROM CURRENT_DATE()) ) AND (m9upgradeyr <= EXTRACT(YEAR FROM CURRENT_DATE()) + 12 )"

While the version based on the text year field worked for display purposes, I had to change the underlying data to be a date field because the date slider widget I was using in WebApp Builder wasn't honoring the query expression. Once I changed it to hit an actual date field, all was well.

Steve

DanteLee
Occasional Contributor II

Ah! Thanks for the thorough response. I have some use cases for this, but not what inspired my initial search. I was hoping I could've referenced the Arcade field in this backend workaround. I did a point-poly intersection via an Arcade expression, and I'm looking to filter out the point if its corresponding poly was also filtered out.

0 Kudos