ArcGIS Online- Map Viewer- Filter Expression option for 'Within the Current Year'

255
8
2 weeks ago
Status: Open
Amanda__Huber
MVP Regular Contributor

Hello AGOL Team, 

In Map Viewer it appears there is is no filter option for "within the current year". Our organization desperately need this (as I'm sure many others do as well). For some of our production projects we have filters set to the current year, and every year we have to manually go into these web maps and update the year/date in the filter. 

Amanda__Huber_0-1714505334938.png

 

Please consider adding a filter for "within the current year". 

 

In addition, please note the difference in variety of filter options between Map Viewer and even ArcGIS Dashboards. Please consider filter equivalency between the two platforms: 

Amanda__Huber_1-1714505541848.png

Thank you, 

Amanda Huber

 

8 Comments
sondickerson

Is it possible to use an arcade expression in your query - and use Year(Now())

RussRoberts

Is this a Date Only field or the classic Date-Time on a hosted feature layer?

 

We do support this type of relative filtering in Map Viewer with Date-Time and have Date Only support coming in the next update. 

RussRoberts_0-1714526024558.png

 

Amanda__Huber

Hi @RussRoberts , 

Thanks so much for your response, that's great to hear! 

 

To clarify your definition of "Date Only" and "Date Time"- 

I did some digging and we're working with a federated Enterprise service (coming from our SDE). At the SDE level this field is labeled as a "date" field but is "date-time" field

Amanda__Huber_1-1714594200537.png

Amanda__Huber_3-1714594575420.png

 

In the service, the field is defined as a "Date" type also: 

Amanda__Huber_4-1714594699779.png

 

 

If I'm understanding correctly, when you refer to "date-time" that should be referring to the field type that we're using (defined at the SDE level), correct? If so, is there a reason we are unable to see the options you're suggesting we should see? 

We've been able to reproduce this behavior across other datasets that are also using SDE "date-time" fields. 

 

Update- Tested this workflow on an AGOL hosted feature layer as well (cut of the data) and we able to see the additional expression options. 

Amanda__Huber_0-1714595064503.png

 

Unfortunately "in the last" still isn't quite what we're looking for thought. We're looking for "In the Current"  such as current Year, current Month, or Current Day. 

 

Thanks,

Amanda Huber

 

 

 

SteveCole

@Amanda  There's an old, open idea for adding support for Arcade based fields inside layer definition queries that you could vote up. This would be one option, if it was supported. You could create an Arcade field that is coded YES/NO based on evaluating your date field against the current year.

Outside of that, there is another option which is a pain in the butt but you can decide if the hassle factor is worth it. Simply put, you can use ArcGIS Assistant to edit the underlying definition query for the layer you're interested in. The SQL that's used does support some date manipulation so it's a matter of finding the right syntax for querying records within the current year.

I had to use this approach in order to add some date filtering to a data layer in one of my maps (that thread is here).

Amanda__Huber

Hi @SteveCole thanks for that info, I'll definitely kudos that arcade post.

 

That's an interesting workaround. I'm a little hesitant to use AGOL Assistant because it's technically " not supported by Esri" (last I knew), but just to confirm, ArcGIS assistant supports "in the current" as a query? Does the year need to be hard coded or is it dynamic (meaning it will update itself every year)? I'll do more digging to see the sql that you're referring to also. 

 

Looking forward to hearing what Russ has to say too.  

Thanks!

 Amanda Huber

SteveCole

@Amanda__Huber Yeah, it is unsupported so you'll want to consider that. If it's a "read only" map where you're not enabling users the ability to alter the layer's definition query, it's probably ok.

ArcGIS Assistant doesn't support "in the current" per se- it's simply an editor for the underlying editor for all the JSON that defines  a map & it's contents. What will support "in the current" will be the SQL query language of the database that houses the data so that might be Microsoft SQL Server SQL or Oracle's flavor of SQL. That's where you'll need to dig and experiment.

Either way, you will NOT want to tweak this inside of the ESRI Map Viewer once you have it set up (because it doesn't support it within the UI so it might blow it out). Again, you'll need to evaluate if the risk/reward is worth it for your situation.

Amanda__Huber

@RussRoberts any update on this? Thanks!

RussRoberts

Hey @Amanda__Huber We are looking into it. It will be similar to the hosted case posted above with the "In the last" and then you would pick the unit of time similar to the hosted case.