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 arsons 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).
- Open the map with the filtered layer in the map viewer.
- Click Details and click Contents.
- Browse to the feature layer with the existing filter and click Filter .
- 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, ArcGIS Server feature service layers, and ArcGIS Server map service layers that have associated attribute data; you cannot create filters on map notes or features imported from a file. Only the features that meet the expression criteria will be visible in the map.
- Open the map in the map viewer.
- Click Details and click Contents.
- Browse to the feature layer you want to filter and click Filter .
- 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.
- 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 each 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 versus 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 box to the left of Ask for values. 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 to the right of your expression.
- 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.
- To undo the filter and show all the features in the layer, click Remove Filter.
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.
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.
- Open the map in the map viewer.
- Click Details and click Contents.
- Browse to the feature layer you want to filter and click Filter .
- Create your definition expression for the date filter as follows:
- Select a date field from the Field drop-down menu.
- Select an operator—for example, is on, is before, is after, and so on—from the Operator drop-down menu.
- 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 versus the value in another field, click Field and select a field from the drop-down menu.
- Add more expressions or sets as needed.
- When you are finished, click Apply Filter.
Considerations for filters
- You can create filters on hosted feature layers, hosted feature layer views, GIS Server feature service layers, and GIS Server map service layers that have associated attribute data. 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).
- If you have multiple expressions, your results vary depending how and if you group them in sets. For example, if you create a filter where all of the following expressions must be true, Type is middle or Type is secondary (this is a set) and Category is private (this is a single expression), the filter selects private middle schools and private secondary schools.If you instead create your filter where the following must be true, Type is secondary and Category is private (now this is your set) or Type is middle (this is a single expression), then your filter selects all public and private middle schools and private secondary schools.