Filter widget

The Filter widget allows you to limit the visibility of features in one or more layers to only those that meet the expression criteria. You can apply filters to multiple layers with group filters. Changes made in a Filter widget affect data across your app, so other widgets that use the same layers are filtered accordingly.

Examples

Use this widget to support app design requirements such as the following:

  • You have a large dataset and want to provide different audiences with relevant options to filter the data by what matters to them.
  • You want to change the visibility of features in all the widgets that use the same layer in your app.
  • You want to filter features across multiple data sources based on a common value.

Usage notes

The Filter widget requires that a data source be set for each filter that you add. You can set actions for a Filter widget to interact with other widgets, such as zooming to the selected feature on a map in a Map widget. Each filter can be turned on or off by end users to control the visibility of features. When you configure multiple filters for this widget, you can specify whether all enabled filters must be true to show the data or whether any can be true to show the data.

If you want users to create their own filter clauses at run time, you can add custom filters in the Filter widget's settings. When you add a custom filter, you choose the data, and at run time the user can add clauses and clause sets using an expression builder.

Settings

The Filter widget includes the following settings:

  • New filter—Create a single filter by selecting a data source and adding expressions. The Create new filter panel that appears includes the following settings:
    • Data—Select the data that you want to filter. You can only select one data source per filter. Filters support feature layers, feature layers in selected web maps, data views, and feature service URLs. If a data source has any associated data views, they are available to choose in the drop-down list.
      Note:

      The Filter widget does not support Web Feature Service (WFS) layers in web maps.

    • Label—Provide a meaningful name for the group filter. By default the label is the name of the data source.
    • Icon—Choose an icon for each filter. You can choose icons from the General and Arrows galleries, or add your own icon from a file. Click the Delete button to remove unused uploaded icons.
      Note:

      You can upload the following image formats: PNG, GIF, JPG, JPEG, and BMP. To preserve optimal performance, there is a 10MB size limit for each upload.

    • SQL Expressions—Build SQL expressions to specify the filter criteria. The SQL Expression Builder provides several options for creating complex and interactive queries.
    • Options—You can turn on the following options for each filter:
      • Apply this filter automatically—When users open the app, this filter is already applied to the data. Users can turn off the filter in the widget.
        Note:

        If a filter widget is nested in a Widget Controller, the filter won't be automatically applied to the data until the widget panel is opened (either manually or configured to open in the Widget Controller settings).

      • Collapse filter details (if any) automatically—Turn on this setting to have filter panels be collapsed by default. If the filter is configured to ask for values, users must click to expand the filter to see the additional details. This setting is useful for saving space if you have many filters.
  • New group—Click the drop-down menu button then click New group to create a group filter. The Create new group panel that appears includes the following settings:
    • Data—Select the data that you want to filter. You can select multiple data sources. Group filters support feature layers, feature layers in selected web maps, data views, and feature service URLs. If a data source has any associated data views, they are available to choose in the drop-down list. Output data sources are not supported.
    • Label—Provide a meaningful name for the group filter. When you add a group filter, by default its label follows a continued numbering rule.
    • Icon—Choose an icon for the group filter. You can choose icons from the General and Arrows galleries or add your own icon from a file. Click the Delete button to remove unused uploaded icons.
      Note:

      You can upload the following image formats: PNG, GIF, JPG, JPEG, and BMP. To preserve optimal performance, there is a 10MB size limit for each upload.

    • SQL Expressions—Build SQL expressions to specify the filter criteria. The Group SQL Expression Builder provides several options for creating complex and interactive queries.
    • Options—You can turn on the following options for each group filter:
      • Apply this filter automatically—Turn on this setting to apply the filter to the data automatically when the user opens the app.
      • Collapse filter details (if any) automatically—Turn on this setting to have filter panels be collapsed by default. If the filter is configured to ask for values, users must click to expand the filter to see the additional details. This setting is useful for saving space if you have many filters.
  • New custom filter—Click the drop-down menu button then click New custom filter to create a custom filter. A custom filter is a filter where the user creates the clause or clause set at run time. The Create new custom filter panel that appears includes the following settings:
    • Data—Select the data that you want users to use to make custom filters at run time. You can select multiple data sources. Output data sources are not supported.
    • Label—Enter a meanungful label for the custom filter.
    • Icon—Optionally, change the icon for the custom filter.
  • When you add multiple single filters or groups, click AND to specify that all filter criteria must be true or click OR to specify that any filter criteria can be true. You can also drag the filters and groups to change their order.
  • You can use the Duplicate and Remove buttons that appear next to each filter and group to duplicate and remove them.
  • Arrangement style—Choose from Vertical, Horizontal, or Icon to customize your desired style for filters in one widget.
  • Activation style—Choose either Toggle switch or Button as the style to turn on or off each filter. (The default style is Toggle switch.)
    • Exclude activation styles for single clause—If there is only one clause, and it's asking for values (or displaying label) in each filter, this option allows you to exclude the activation styles (along with the label and the icon), display the clause content directly, and auto-apply it.
  • Advanced tools—Configure advanced tools.
    • Reset all filters—Include a button for users to reset all filters to their original configured states.
      Tip:

      The List widget's filter tool provides a reset button by default.

SQL Expression Builder

A filter uses logical expressions to find and display features in a layer based on attribute values in its data. Expressions use the general form of <Field name> <operator that specifies a condition> <Value or Field>. For example, Shelter capacity is greater than 200.

To create expressions in the SQL Expression Builder, click Add clause or Add clause set.

The expression for each clause includes the following parts:

  • Field—Select a field from the data source to filter on. The three field types are number, string, and date. Representative icons appear next to the field names.
  • Operator—Select a functional operator to evaluate the data values for the selected field. Operators vary depending on the field type. View a full list of supported operators for each field type.
  • Value—Type or select a value to complete the clause. Click the Select source type button Select source type to choose a value, such as user input, field, unique, unique (predefined), multiple, and multiple (predefined).
Note:

If you connect the filter to an output data source, you can't choose the values for it in the settings (except for coded values). The list of values is dynamically generated at runtime after the output data is created by the source widget. For this reason, Ask for values is checked by default and predefined values can only be typed in.

For each clause, you can set the following additional options:

  • Case sensitive—To meet filter criteria, data must match the use of lowercase and uppercase in the clause values. This option is only applicable to string fields in non-hosted layers (the button is unavailable for hosted layers).
  • No user input—By default, the clause does not ask for input from users. You can check the Display label option to only display the default or customized labels to users.
  • Ask for values—Allows users to provide custom input and change filters at run time. You can do the following:
    • Choose an input style (if there are multiple styles available based on the value source type you selected).
    • Customize the label.
    • Customize the label position. You can choose wrap in different line or in the same line with input.
    • Provide a hint or instruction to users.
    • Choose criteria for the values list that users see in the filter options (only applicable to unique and multiple source types). You can show all values, filter values based on a previous expression, or filter values based on all the expressions.
      Note:

      Predefined values allow you to filter based on a value or values that you choose from a static list or type directly. By default, Ask for values is checked and the list is set to show values based on the previous expressions. You can also drag the values to move them and change the order.

  • Duplicate—Duplicate a single clause or an entire clause set and add it to the end of the queue inside the SQL Expression Builder. If inside a clause set, this button duplicates a single clause and adds it to the end of the clause set.

If you add more than one clause or clause set to the filter, click AND to specify that all filter criteria must be true or click OR to specify that any filter criteria can be true. You can also configure this setting for the clauses in a clause set.

Group SQL Expression Builder

The Group SQL Expression Builder allows you to make logical expressions for group filters, which filter multiple data source fields based on common values. The expression includes the following parts:

  • Main field—The field that you use to set the operator and values for the rest of the fields in the group filter.
  • All fields—All the fields filtered by the group filter, including the main field. You can use the drop-down lists to select fields from the connected data sources. You can only select fields that are of the same field type (string, date, or number) as the main field. If you select multiple fields from one data source, click AND to specify that the value must exist in both fields or click OR to specify that the value can exist in any field.
  • Operator—Select a functional operator to evaluate the data values for the selected fields. Operators vary depending on the field type of the main field. View a full list of supported operators for each field type.
  • Value—Type or select a value to complete the expression. Click the Select source type button Select source type to choose a value, such as user input, field, unique, unique (predefined), multiple, and multiple (predefined).

You can configure the following additional options for the expression:

  • Case sensitive—To meet filter criteria, data must match the use of lowercase and uppercase in the main field value. This option is only applicable to string fields in non-hosted layers (the button is unavailable for hosted layers).
  • No user input—By default, the expression does not ask for input from users. You can check the Display label option to only display the default or customized labels to users.
  • Ask for values—Allow users to provide custom input and change filters at run time. You can do the following:
    • Choose an input style (if there are multiple styles available based on the value source type you selected).
    • Customize the expression label.
    • Customize the label position. You can choose wrap in different line or in the same line with input.
    • Provide a hint or instruction to users.
    • Choose criteria for the values list that users see in the filter options (only applicable to unique and multiple source types).

Operators

The following table lists field types and their supported operators:

OperatorNumberStringDate

is

Yes

Yes

is not

Yes

Yes

is at least

Yes

is at most

Yes

is less than

Yes

is greater than

Yes

is between

Yes

Yes

is not between

Yes

Yes

starts with

Yes

does not start with

Yes

ends with

Yes

does not end with

Yes

contains

Yes

does not contain

Yes

is any of

Yes

Yes

is none of

Yes

Yes

is on

Yes

is not on

Yes

is in

Yes

is not in

Yes

is before

Yes

is after

Yes

is on or before

Yes

is on or after

Yes

is in the last*

Yes

is not in the last*

Yes

is in the next*

Yes

is not in the next*

Yes

is blank

Yes

Yes

Yes

is not blank

Yes

Yes

Yes

*Only applicable for ArcGIS Online hosted feature services.