Group and use AND/OR filter logic without the need to manually create filter expressions in an Explore.
Creating AND/OR filters
AND/OR filters appear in the Filters section in an Explore above your results. You can customize filters with AND/OR logic when you add or edit a filter on an Explore.
You can add a filter in several ways:
- Select a field's Filter by field icon field picker. in the Explore
- Select the Filter option from a field's data table gear menu.
- Select the Filter button in the Filters section of the Explore.
To remove a filter, click the Remove X
icon next to the filter.
Filter section options
When you add more than one filter, the option to specify between AND
and OR
filter logic and switch between them appears to the left of the filter fields. A new filter group creates a separate set of filters with the option to specify between AND
and OR
filter logic between groups. The filters section contains the following options:
- AND/OR logic button — Select this option to switch filter logic. It will say AND or OR depending on the logic selected. Important: Depending on the filter conditions, the AND or OR buttons may be unactionable, indicating that the logic cannot be switched.
- + Filter button — Select this option to add another filter in the same group.
- + New Group button — Select this option to create a new filter group.
- + Custom expression button — Select this option to create a custom expression manually using Lexp.
Filter groups
Filters can be sorted into separate groups that are connected through AND/OR filter logic. For example, there can be multiple filters in groups A and B, and you can set the Explore to filter on group A
OR group B
. Groups allow you to filter Explores for multiple conditions that are not directly related.
For example, the following Explore filters contain two groups separated with OR logic:
- Orders Status is
pending
AND Users State isCalifornia
OR - Products Category is
active
AND Inventory Items Cost is <=100
The resulting explore will show order data of pending
orders in California
OR orders that contain Active
category goods costing less than or equal to 100
.
AND/OR filters and required filters
Required filters (for example, a filter that is required with the always_filter
parameter or conditionally_filter
parameter) always appear in the first filter group, or group A
.
To add multiple filter conditions to a field that is referenced by a required filter, click the Add button OR
filter logic will automatically be applied between each condition that is added to the required filter field.
You can add multiple filters to group A
by clicking the + Filter button, and you can add subsequent filter groups by clicking + New Group.
AND/OR filters on dashboards
AND/OR filters are created in the Explore Filters section and are translated into Looker expressions before the query is run. As a result, AND/OR filters behave differently from basic filters on dashboards.
If a query that uses both AND and OR filters is added to a dashboard, the filters will not appear in the dashboard filters section. The filters are still applied to that query, and can be edited in the corresponding query tile.