Apply filters (Map Viewer)

You can use filters to present a focused view of a feature layer in a map. By limiting the visibility of features 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 layers currently do not support filtering in Map Viewer (formerly a separate beta installation now included in the portal automatically). You can filter imagery layers based on mosaic datasets in Map Viewer Classic (formerly Map Viewer).

Filter expressions

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

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, choosein 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 Match all expressions option is selected. This means that only the features 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 Match at least one expression 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 Match at least one expression 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 into sets.

As you set up the filter, features 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 are hidden.

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 content.
  2. In Map Viewer, open the map containing the layer or add the layer directly.
  3. On the Contents (dark) toolbar, click Filter Filter.
  4. Create a filter expression as follows:
    1. In the Filter pane, click Add expression.
    2. Click the field selector, select a field to use for the expression, and click Replace.
      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 field, additional date operators become available. You can use the in the last and not in the last operators to apply a dynamic 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. Other available operators for date filters include is on, is not on, is before, is after, is between, and is not between.

    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 expressions to the filter:
    1. Click Add expression 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 set.

      To delete an expression, click Options and click Delete expression.

    2. Click the Filter results drop-down menu and select a matching option.

      Match all expressions shows features that match all of the filter expressions. Match at least one expression shows features 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 the filter, click Remove Remove.

Use expression sets

To create a more complex filter, you can use expression sets to group multiple expressions. The way in which you group the expressions determines what you see on the map. For example, you can use expression sets 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 sets 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 expression sets.

To create a filter using expression sets, do the following:

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

    A new set 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 set, click Add condition and repeat the previous step for each expression.
  5. Click the drop-down menu for the set and select a matching option.

    Match all conditions shows features that meet all conditions in the set. Match at least one condition shows features that meet at least one condition in the set—for example, incidents with the primary type of arson or theft.

  6. Optionally, repeat the previous steps to create additional filter sets.
    Tip:

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

    To delete a set, click Options and click Delete set.

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