Apply filters (Map Viewer Classic)

Note:

This topic includes information related to Map Viewer Classic. An enhanced map viewer is now available. Open Map Viewer from the app launcher to get started. To learn more, see the Map Viewer help documentation.

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 Classic.
  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 and ArcGIS Server feature 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 Classic. 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 Classic.
  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. For more information about sets and to see an example, see the Considerations section.
    • 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. If this option is not available, restrictions may apply.
    • 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 organization 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 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 Classic.
  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.

    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.
      • If you want to filter based on a specific value in the date field you selected for your expression, click Unique and select a unique date value. If this option is not available, restrictions may apply.
  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 work with filters:

  • You can create filters on hosted feature layers, hosted feature layer views, and ArcGIS Server feature 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.
  • You can filter date fields on hosted feature layers as well as on ArcGIS Server 10.2 and later service layers that support standardized queries.
  • 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 requires a 10.1 or later map service layer. The option does not appear if you are filtering a 10.0 or earlier map service layer.
  • 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.
  • Grouping multiple expressions into sets and the way in which you group the expressions determine what you see on the map. For example, this map uses expression sets to filter a layer of police incidents in Philadelphia, Pennsylvania. In this example, the map author wants the map to show police incidents that were firearm-related or that resulted in a death, while filtering out other types of incidents such as thefts not involving firearms. Additionally, the map author is only interested in showing the firearm and deadly incidents that occurred in 2016.

    To accomplish this, the filter requires four distinct expressions: one for each of the three incident types the map author wants to show (Robbery Firearm, Homicide – Criminal, and Aggravated Assault Firearm) and one for the year that is of interest (2016). Grouping the year expression with each of the incident type expressions using sets ensures that the map displays only the incidents for which both of the following are true:

    • The incident type is Robbery Firearm, Homicide – Criminal, or Aggravated Assault Firearm.
    • The incident occurred in 2016.