HOW TO

Create a dynamic date filter for a feature layer using Arcade in ArcGIS Online

Last Published: December 23, 2024

Summary

A dynamic date filter can be applied to a feature layer within a web map to filter the layer on specified dates. The filter can be used, for example, to show all the daily updates made to the layer, instead of manually updating the filter on the web map each day.

This article highlights the workflow to create a dynamic date filter for a feature layer using a custom Arcade expression.

Procedure

  1. In ArcGIS Online Map Viewer, on the Contents (dark) toolbar on the left of the page, click Layers.
  2. Expand the hosted feature layer and select the feature to open the Properties pane.
  3. On the Settings (light) toolbar, click Styles.
Styles
  1. In the Styles pane, click Expression.
Select Expression
  1. In the Arcade expression editor window, under Expression, insert the following expression:
Expects($feature, 'Date_Field_Name')

var time = -1
var units = 'days'  //milliseconds, seconds, minutes, hours, days, months, years
var dateField = "Date_Field_Name"

var pastDate = DateAdd(Date(), time, units)
if($feature[dateField] > pastDate)
{
    return 'Open'
}
Note:
Change the first three variables to any desired value. The supported units are milliseconds, seconds, minutes, hours, days, months, and years. The dateField variable is the date field queried.
  1. Click OK.
  2. Set a refresh interval for the feature to update dynamically. Refer to ArcGIS Online: Set refresh interval (Map Viewer) for instructions.

The map shows the custom dynamic date filter created for the feature layer.

A custom style is created

Article ID: 000027700

Software:
  • ArcGIS Online

Get support with AI

Resolve your issue quickly with the Esri Support AI Chatbot.

Start chatting now

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Start chatting now

Go to download options