Skip To Content

Apply filters

A filter presents 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. For example, you might create a filter on 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.

As a map author, you can also set up interactive filters that help your audience explore data themselves. By providing prompts and hints about the available values in the layer, you can guide your audience toward other filters they might want to apply on the features. For example, you might set up an interactive filter on a schools layer so your audience can choose to see elementary, middle, or secondary schools. By default, the layer shows elementary schools. By reading the prompt and hint you've supplied, your audience knows they can change the value to middle or secondary to see different types of schools on the map.

Work with existing filters

If a map feature layer contains a filter, you see a filtered view of the features. Only the features that meet the filter criteria appear on the map. For example, a map author may have set up a filter on a schools layer that contains elementary, middle, and secondary schools to only show the elementary schools (for example, Type is Elementary). In this case, middle schools and secondary schools are filtered out of the map display. If the map author set up an interactive filter on the schools layer, you can change the value to Middle and now see just the middle schools in the area.

You can access the filter to view the expressions, change any interactive expressions in the filter, and edit the filter. Any changes you make only apply to your view of the map (unless you own the map, in which case, you can save your changes).

  1. Open the map with the filtered layer in Map Viewer.
  2. Click Details and click Content.
  3. Browse to the feature layer with the existing filter and click Filter Filter.
  4. Change, edit, or view the filter.
    • On the Change tab, you can apply a new value for an existing interactive filter. Enter a new value for the expression and click the Apply Filter button. The map display updates with the new filtered view of the feature layer. The tab also displays friendly versions of the expressions in the filter. This tab appears if there are interactive expressions in the filter. If the filter does not contain interactive expressions, you see a View tab instead with friendly versions of the expressions in the filter.
    • On the Edit tab, you can update the expressions. See the next section for details on how to update the expressions.

Create filters

You can create filters on hosted feature layers, hosted feature layer views, ArcGIS Server feature service layers, and related tables in ArcGIS Server map service layers; you cannot create filters on map notes or features imported from a file. Only the features that meet the filter's expression criteria will be visible in the map.

The following steps explain how to apply filters in Map Viewer. For feature layers, you can also apply filters on the Visualization tab of the feature layer's item page.

  1. Open the map in Map Viewer.
  2. Click Details and click Content.
  3. Browse to the feature layer you want to filter and click Filter Filter.
  4. Create your definition expression.
    • Expressions use the general form of <Field_name> <Operator> <Value, Field or Unique>.
    • You can create one expression, multiple expressions, or one or more sets of expressions. A set is a grouping of expressions, for example, Type is elementary and Enrollment is at least 400. To create a set of expressions, click Add a set.
    • If you have more than one expression, choose to display features in the layer that match All or Any of your expressions. All requires that all of the criteria you have specified must be true. Any means that only one of your expressions must be true for the features to display.
    • For the field part of the expression, click the Field drop-down arrow and choose the field you want to query against from the list.
    • For the operator part of the expression, click the Operators drop-down arrow and choose an operator from the list.
    • If you want to filter based on a specific value, choose Value and enter a value in the field. The input box varies depending on the field type.
    • If you want to compare the value in one field with the value in another field, choose Field, click the drop-down arrow, and choose the field for your expression.
    • If you want to filter based on a specific value in the field you've selected for your expression, choose Unique and select a unique value from your field.
      Note:

      Unique value filters are not supported on date fields.

    • If you created an expression based on values or a unique value, you can set up an interactive expression. You cannot ask for values on expressions based on a field. Click the Ask for values box. Enter information about the value in the Prompt field and a hint in the Hint field.
    • To delete an expression in the filter, click the Delete button Delete to the right of your expression.
  5. Click Apply Filter to enable the filtered view on the map.
    Tip:

    If you created a filter for a hosted feature layer, you have the option to Apply Filter And Zoom To, which enables the filtered view and redraws the current map to show the filters.

  6. Feature layer owners and portal administrators can save the filter to the layer. Click More Options More Options and click Save Layer.

    When you save the filter with the layer, everyone who accesses the layer sees the filtered data. If you do not save the filter to the layer, the filter is only applied in the map.

  7. To undo the filter and show all the features in the layer, click Remove Filter.

    If you saved the filter to the layer, you'll need to save the layer again to remove the filter from the layer.

Filter by date

You can filter some feature layers by date. For example, you may want to show the locations of earthquakes that occurred during a specified date range.

Using the in the last and not in the last operators, you can also apply a dynamic date filter to a hosted feature layer to show events that occurred relative to the current day—for example, all features that were edited in the last five days—without having to manually update 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.

Note:

Filtering by date is available for hosted feature layers and ArcGIS Server 10.2 and later service layers that support standardized queries.

  1. Open the map in Map Viewer.
  2. Click Details and click Content.
  3. Browse to the feature layer you want to filter and click Filter Filter.
  4. Create your definition expression for the date filter as follows:
    1. Select a date field from the Field drop-down menu.
    2. Select an operator—for example, is on, is before, in the last, and so on—from the Operator drop-down menu.
      Note:

      The in the last and not in the last operators are only available for hosted feature layers, not for hosted spatiotemporal feature layers or ArcGIS Server feature services.

    3. Do one of the following, depending on how you want to filter the data:
      • If you want to filter based on a specific date value, click Value and enter a value. Depending on the operator you selected, you might 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.
      • If you want to compare the value in one field with the value in another field, click Field and select a field from the drop-down menu.
  5. Add more expressions or sets as needed.
  6. When you are finished, click Apply Filter.

Considerations for filters

Keep the following in mind when you're working with filters:

  • You can create filters on hosted feature layers, hosted feature layer views, ArcGIS Server feature service layers, and related tables in ArcGIS Server map service layers. You cannot create filters on map notes or features imported from a file.
    Note:

    Filters applied to hosted feature layers and hosted feature layer views do not restrict access to the layer's data. Anyone with access to the layer can remove the filter and access all the data.

  • To change a field name, edit the field alias through a pop-up configuration.
  • You can create interactive expressions based on values or unique values. You cannot create interactive expressions based on a field.
  • Do not add special characters to your values unless those special characters are part of the value. For example, City is "New York" doesn't find a feature named New York. In this example, use City is New York instead.
  • If your field includes coded values, the Values list shows all coded values defined by the service for the field. This may include values that do not exist as features in the layer. The Unique list shows all the features in the layer (which may be a subset of the values in the service).
  • The Unique option is not available if the number of unique values exceeds the limit allowed by the layer. You can instead use the Value option to explicitly type the value used for the filter.
  • If you have multiple expressions, how and if you group the expressions in sets affects the filter expression definition and what you see in the map. In the following example, any private school that is a junior high or high school will draw on the map.

    Example of a filter

    That's because the values must be true for any of the expressions in the expression set (Type is Junior High or Type is High School) but must be true for both the expression set and the additional expression (Category is private).

    Filter definition when any expression in a set is true but all expressions overall must be true

    If you instead create your filter so that values must be true for both parts of the expression set (Type is High School and Category is private) but can be true for either the expression set or the additional expression, (Type is Junior High), the filter selects all public and private junior high schools and private high schools.

    Filter example when any expressions can be true

    Filter definition when all expressions in a set must be true but any expressions overall can be true