A filter presents a focused view of a feature layer in a map. Limiting the visibility of features in a layer helps to reveal the important aspects of the layer. For example, if you have a layer showing shark attacks, you can create a filter to show the areas with the most attacks. By showing patterns of the most attacks in an area, you can help your city to warn future beachgoers about potential attacks.
Create filters
You can create filters on hosted feature layers, hosted feature layer views, ArcGIS Server feature service layers, and ArcGIS Server map service layers that have associated attribute data. Only the features that meet the expression criteria appear in the map.
Note:
Layers added from the following file formats do not support filters: CSV, TXT, GPX, GeoJSON, and shapefile.
- In the Contents pane of the Compilation window, point to the layer's options button and click Filter .
- In the Filter window, use the lists and options in the builder to define one or more expressions or add a set (a grouping of expressions, for example, Type is elementary and Enrollment is at least 400).
Expressions use the general form of <Field_name> <Operator> <Value, Field, or Unique>.
- For the field part of the expression, click the Field drop-down arrow and choose the field you want to query against.
Note:
If the layer has several fields, you can type a search term in the box to reduce the list of field names.
You'll see field aliases instead of the field names from the data if the layer has field aliases defined.
- For the operator part of the expression, click the Operators drop-down arrow and choose an operator.
- For the final part of the expression, choose from one of the following options:
- 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.
- 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.
- To filter based on a specific value in the field you've selected for your expression, choose Unique and select a unique value from the data. Unique value filters require a 10.1 or later map service layer. The Unique option does not appear if you are creating a filter on a 10.0 or earlier service layer.
- For the field part of the expression, click the Field drop-down arrow and choose the field you want to query against.
- If you add more than one expression, choose to display features in the layer that match All or Any of the expressions.
All requires that all of the criteria you have specified must be true. Any means that only one of the expressions must be true for the features to display.
- Click Apply Filter to enable the filtered view on the map.
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, is not between, and so on.
- In the Compilation window, add data with date fields.
- In the Contents pane, point to the layer's options button and click Filter .
- Create a filter expression as follows:
- Select a date field from the Field drop-down menu.
- Select an operator from the Operator drop-down menu.
Note:
The in the last and not in the last operators are only available for hosted feature layers.
- Depending on how you want to filter the data, do the following:
- To filter based on a specific date value, click Value and enter a value. Depending on the operator you select, 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.
- To compare the value in one field with the value in another field, click Field and select a field from the drop-down menu.
- To filter based on a specific value in the date field you selected for your expression, click Unique and select a unique date value.
Access existing filters
You can access the filter to view the expressions and edit the filter. Any changes you make only apply to your view of the map.
- In the Contents pane of the Compilation window, point to the layer's options button and click Filter.
- Modify or remove the filter.
- On the View tab, view the filter expressions applied to the layer or click Remove Filter.
- On the Edit tab, change, delete, or add expressions.
Considerations
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 ArcGIS Server map service layers that have associated attribute data.
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 the data.
- 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. This option does not appear if you are filtering a 10.0 or earlier map service layer. If you have multiple expressions, your results will vary depending on 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), the filter selects all public and private middle schools and private secondary schools.