Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion references/metrics.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,9 @@ filters:

### Filtering using a list of values

To filter a field using a list of values you can supply them as an array for that field. For example, if you wanted to filter for orders with order status `completed` or `shipped` you should write the metric like:
To filter a field using a list of values you can supply them as an array for that field. This generates a SQL `IN` clause, e.g. `WHERE order_status IN ('completed', 'shipped')`.

For example, if you wanted to filter for orders with order status `completed` or `shipped` you should write the metric like:

<Tabs>
<Tab title="dbt v1.9 and earlier">
Expand Down
30 changes: 22 additions & 8 deletions references/tables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ The order that the fields are listed in `default_show_underlying_values` is the
Use `default_filters` to define filters on Dimensions that will be applied when no other user-defined filter on those Dimensions exists. Default filters will apply to tables on load and can be populated with a pre-determined value. Use them to suggest to users the kind of filters they might want to consider, or provide a default filtered view of a table that can be changed if needed.

An optional `required` flag can be added, and if this flag is set to `required: true`, the filter for this field cannot be removed from the UI but users can still modify the operator and value to adjust how this filter is applied to the data. This ensures the filter is always applied in some form, while giving users flexibility to change the date range or other values. This can be particularly useful if you have a large table and want to force users to filter on a partitioned date.

In contrast, when `required: false` (or omitted), the filter is pre-populated but fully editable — users can change the field, operator, value, or remove it entirely.

Below you can see there is a default filter with the optional required flag, that will have show the last 14 days of data by default.
Expand Down Expand Up @@ -802,7 +802,7 @@ Note that we do also support a _legacy_ structure for defining required filters,
| is not empty | Value is not empty string | `notes: "!empty"` | String |
| is [boolean] | Boolean value is true | `is_complete: "true"` | Boolean |
| is not [boolean] | Boolean value is false or null | `is_complete: "!true"` | Boolean |
| in list | Value is in comma-separated list | `status: "active,pending,approved"` | String, Number |
| in list | Value is in a list of values | `status: ["active", "pending", "approved"]` | String, Number |


### Filter examples
Expand All @@ -824,12 +824,20 @@ default_filters:
- created_at: 'between 2024-01-01T00:00:00 and 2024-12-31T23:59:59'
```

**Multiple values (comma-separated list):**
**Multiple values (list):**

Use an array to filter by multiple values. This generates a SQL `IN` clause, e.g. `WHERE status IN ('active', 'pending', 'approved')`.

```yaml
default_filters:
- status: 'active,pending,approved'
- country: 'US,CA,UK'
- status:
- 'active'
- 'pending'
- 'approved'
- country:
- 'US'
- 'CA'
- 'UK'
```

**Pattern matching:**
Expand Down Expand Up @@ -862,7 +870,9 @@ Available intervals: `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `wee
- name: orders
meta:
default_filters:
- status: 'completed,shipped'
- status:
- 'completed'
- 'shipped'
- order_date: 'between 2024-01-01 and 2024-12-31'
- revenue: '>= 100'
- country: '!test'
Expand All @@ -876,7 +886,9 @@ Available intervals: `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `wee
config:
meta:
default_filters:
- status: 'completed,shipped'
- status:
- 'completed'
- 'shipped'
- order_date: 'between 2024-01-01 and 2024-12-31'
- revenue: '>= 100'
- country: '!test'
Expand All @@ -889,7 +901,9 @@ Available intervals: `milliseconds`, `seconds`, `minutes`, `hours`, `days`, `wee
name: orders

default_filters:
- status: 'completed,shipped'
- status:
- 'completed'
- 'shipped'
- order_date: 'between 2024-01-01 and 2024-12-31'
- revenue: '>= 100'
- country: '!test'
Expand Down
Loading