The Filter widget allows you to limit the visibility of features in one or more layers to only those that meet the expression criteria. Changes made in a Filter widget affect data across your app, so other widgets that use the same layers are filtered accordingly.
Use this widget to support app design requirements such as the following:
- You have a large data set and want to provide different audiences with relevant options to filter the data by what matters to them.
- You want to allow users to change the visibility of features in all the widgets that use the same layer in your app.
The Filter widget requires that a data source be set for each filter that you add. 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 if any can be true to show the data.
The Filter widget includes the following settings:
New filter—Create a filter by selecting a data source and adding expressions. The Create new filter panel that opens includes the following properties:
Data—Select the data that you want to filter. You can only select one data source per filter. Feature layers, feature layers in selected web maps, data views, and feature service URLs are supported. You can choose the associated data views listed in the drop-down list if there is any.
Label—Customize the name of each filter.
Icon—Choose an icon for each filter.
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.
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—If the filter is configured to ask for values, users must click to expand the filter to see the additional details. (Turn on this option for a clean look if you have many filters.)
When you add multiple filters, click AND to specify that all filter criteria must be true or click OR to specify that any filter criteria can be true.
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.
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 input boxes:
- 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.
- Value—Type or select a value to complete the clause. Click the Select source type button to choose a value, such as user input, field, unique, unique (predefined), multiple, and multiple (predefined).
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 nonhosted layers (the button is disabled 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—Allow users to customize the input style, 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 content.
Customize the label position: whether to 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 (the latter is only applicable to unique and multiple source type). You can show all values, filter values based on a previous expression, or filter values based on all the expressions.
Unique or multiple (predefined) allows 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.
Duplicate—Allows users to directly duplicate a single clause or an entire clause set and add it to the last in the queue inside the SQL Expression Builder. If inside a clause set, this allows to duplicate a single clause and add it to the last of this 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.