I want to be able to use Arcade expressions in layer filters. I can use Arcade expressions to help style layers in a map, but I cannot use them to filter hosted layer views independent of a map.
In particular, my need is this: I have a hosted layer of projects. The projects have start and end dates - perhaps projected dates - but just the pair of date fields.
I want to create three views from that layer:
A filter "STARTING is before 1/1/2023 and ENDING is after 12/31/2021" is not acceptable as it needs to be updated every January 1st. I want filters that can calculate the current year.
Building a view with the "in the last 1 year" expression available does not work. Today is December 16, 2022. Using "in the last 1 years", returns projects that ended on December 21, 2021. I do not want those projects.
Next month, in 2023, I want the current year layer view to show the 2023 projects.
(edit 6/Feb/2023)
In a map, I can apply "$feature.STARTING < Date(Year(Date())+1,0,1) && $feature.ENDING > Date(Year(Date())-1,11,31,23,59,59)" "Year(Today()) >= Year($feature.STARTING) && Year(Today()) <= Year($feature.ENDING)" to the style to draw only this calendar year's projects.
I want to be able to build a stand-alone view in the form of "STARTING is before Date(Year(Date())+1,0,1) and ENDING is after Date(Year(Date())-1,11,31,23,59,59)" "Year(Today()) >= Year($feature.STARTING) && Year(Today()) <= Year($feature.ENDING)"
I would like to provide another reason for this request.
The current UI limits the ability to use nested expressions as it only allows a depth of 2.
I am currently trying to create a hosted view layer and filter by an expression with the following structure:
(X == 1) AND ((Y == 1) OR (Y == 2 AND Z == 3))
I am unable to nest the underlined expression as the UI doesn't account for the need of parenthetical expressions within parenthetical expressions.
This could be solved by allowing the use of the "Add condition" button to an expression that was added through the "Add condition" button. However, I think the use of Arcade in creating filters will allow for greater control over filters as well as being easier to use. (You can copy and paste arcade rather than use the UI to create the same filter for multiple layers in the same feature service.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.