Apply filters (Map Viewer)

You can use filters to present a focused view of a feature layer or an imagery layer in a map. By limiting the visibility of features or images in a layer, you can reveal what's important to you. For example, you can apply a filter to a crime layer so only arson fires that occurred within the last month appear on the map. By filtering the crime layer based on crime type and date, you can show patterns of where recent fires were set and help your police department prevent future arson attempts.

If the layer includes date fields, you can filter it by date. For example, you can show the locations of earthquakes that occurred during a specified date range, or dynamically show events that occurred relative to the current day.

Note:

Imagery filtering in Map Viewer is only supported for image collections. To identify which imagery layers have associated tables that support filtering, click the Overview tab on the layer's item page and confirm that Image Collection is listed as the Source.

You can filter imagery layers based on mosaic datasets in Map Viewer Classic.

Filter expressions

A filter uses one or more filter expressions to determine which features or images are shown on the map. You create filter expressions using attribute fields in your data.

Each expression includes a field name, an operator, and a value. For example, you can create a filter on a layer containing a city's crime incident data (thefts, arson fires, assaults, and so on) to show only arson fire incidents, as follows:

  • For the field name, choose Primary Type.
  • For the operator, choose includes.
  • For the value, choose Arson.
Tip:

Using the includes operator instead of the is operator provides a list of available values in your data. This is useful when you aren't sure of the exact value. A values list is available for fields that include coded values.

To further refine the filter to show only the arson fire incidents that were reported in the last month, you can create a second expression as follows:

  • For the field name, choose Date.
  • For the operator, choose in the last.
  • For the value, choose 1 month.

If the filter has more than one expression, you must choose a matching option to connect the expressions. In the example above, the All of the following are true option is selected. This means that only the features or images that match all of the filter expressions—in this case, arson fires from the last month—are shown on the map when the filter is applied.

Other filters may require the Any of the following are true option. For example, to show both arson fires and thefts on the map while filtering out other crime incidents, you can create a filter expression to show arson fires (as shown above) and a similar expression to show thefts. Then choose Any of the following are true to show crime incidents that match either the arson or the theft expression.

Create a filter

Creating a filter in Map Viewer involves creating one or more filter expressions and using the appropriate matching option to determine how the expressions are applied to the data. If more advanced matching is required, you can also group filter expressions.

As you set up the filter, features and images that do not match the filter criteria appear gray, or dimmed, on the map until you save the filter. When the filter is saved, these features or images are hidden.

Tip:

You can use keyboard shortcuts to quickly complete common workflows in Map Viewer. To view the full list of keyboard shortcuts in Map Viewer, press Alt+? on Microsoft Windows or Option+? on Mac.

To create and apply a filter, do the following:

  1. Confirm that you are signed in and, if you want to save your changes, that you have privileges to create, update, and delete content.
  2. In Map Viewer, open the map containing the layer or add the layer directly.
  3. On the Settings (light) toolbar, click Filter Filter.
  4. Create a filter expression as follows:
    1. In the Filter pane, click Add new.
    2. Click the field selector and select a field to use for the expression.
      Tip:

      Use the search and sort options in the Replace field window to find a field.

    3. Click the operator selector and select an operator, such as is, is not, includes, excludes, or contains.
      Note:

      If you select a date or date only field, additional operators become available. You can use the in the last and not in the last operators to apply a dynamic relative-date filter to show events that occurred relative to the current day—for example, all features that were edited in the last five days—without manually updating the filter each day.

      Relative-date filter conditions include a range of date values. The range can include the current moment in time (now), or it can be a predefined period (for example, last week). The available range type depends on the operator you choose. Relative-date filter conditions can be applied to date and date only fields in hosted feature layers and ArcGIS Server feature layers (version 10.9.1 or later). See Date and time fields in ArcGIS Enterprise for more information about working with temporal data.

    4. In the value input box, enter a value to use in the expression.

      The input box varies depending on the field type and the operator. For example, if you selected the includes or excludes operator, you select from a list of data values in the specified field.

      If you specified a date field, depending on the operator selected, you can specify a single date (or two dates) from the calendar, enter one or two dates manually, or specify a time range in days, weeks, or months.

  5. Optionally, add another expression to the filter:
    1. Click Add new and repeat the previous step for each new filter expression.
      Tip:

      To create a similar expression to the one you created, click Options Options on the expression and click Duplicate. Make the necessary changes to the duplicate group.

      To delete an expression, click Options and click Delete.

    2. Click the Show features where drop-down menu and select a matching option.

      All of the following are true shows features and images that match all of the filter expressions. Any of the following are true shows features and images that match one or more expressions. For examples of these options, see Filter expressions.

  6. In the Filter pane, click Save to save and apply the filter to the layer.
    Tip:

    To remove an expression from the filter, click Options and click Delete. To remove all expressions, click Clear all.

Use condition groups

To create a more complex filter, you can use condition groups to group multiple expressions. The way in which you group the expressions determines what you see on the map. For example, you can use condition groups to further refine the crime incident filter described above. To show both arson fire and theft incidents reported in the last month while filtering out incidents matching all other crime types and time periods, you can create two groups by grouping the date expression with each of the incident types and choose the option to filter results by matching at least one of the condition groups.

To create a filter using condition groups, do the following:

  1. Follow the first four steps of the Create a filter section above.
  2. On the expression you want to group, click Options Options and click Add condition.

    A new group containing the existing expression and a new empty expression is created.

  3. Add a field, operator, and value for the new expression.
  4. To add expressions to the group, click Add condition and repeat the previous step for each expression.
  5. Click the drop-down menu for the group and select a matching option.

    All of the following are true shows features and images that meet all conditions in the group. Any of the following are true shows features and images that meet at least one condition in the group—for example, incidents with the primary type of arson or theft.

  6. Optionally, repeat the previous steps to create additional condition groups.
    Tip:

    To create a similar group to the one you created, click Options on the group and click Duplicate. Make the necessary changes to the duplicate group.

    To remove an expression from the group, click Remove Remove. To delete a group, click Options and click Delete. To remove all groups, click Clear all.

  7. In the Filter pane, click Save to save and apply the filter group to the layer.