> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omni.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Filters

> Add dimension-based filters to workbook queries to focus on specific data. Configure date, number, and string filter options.

Each dimension can be added as a filter to focus on specific rows of data. Different filtering options will be presented for dates, numbers, and strings:

<img src="https://mintcdn.com/omni-e7402367/UAlPtpzOyrORJCGb/images/docs/querying-and-sql/assets/images/7-date-filter-2c555b6cfbf47fb0a76e17c9d544d8a9.png?fit=max&auto=format&n=UAlPtpzOyrORJCGb&q=85&s=d9cf0329c4a2672f4efe889962a5bd22" alt="" width="1516" height="736" data-path="images/docs/querying-and-sql/assets/images/7-date-filter-2c555b6cfbf47fb0a76e17c9d544d8a9.png" />

<img src="https://mintcdn.com/omni-e7402367/UAlPtpzOyrORJCGb/images/docs/querying-and-sql/assets/images/9-string-filter-fc078a40c6d2699a8a57b1baea51a72b.png?fit=max&auto=format&n=UAlPtpzOyrORJCGb&q=85&s=4633d15ae5b9afeee0e37c63929b4e08" alt="" width="792" height="828" data-path="images/docs/querying-and-sql/assets/images/9-string-filter-fc078a40c6d2699a8a57b1baea51a72b.png" />

<img src="https://mintcdn.com/omni-e7402367/UAlPtpzOyrORJCGb/images/docs/querying-and-sql/assets/images/8-number-filter-d31f3a522ecb7cea6a49ce9a19b44275.png?fit=max&auto=format&n=UAlPtpzOyrORJCGb&q=85&s=3e280fae865aed1e3869851963b14883" alt="" width="816" height="900" data-path="images/docs/querying-and-sql/assets/images/8-number-filter-d31f3a522ecb7cea6a49ce9a19b44275.png" />

To filter using more than one value (equivalent to using `OR`), insert a comma between values: `[bread, cheese]`. If your filter values include commas, you can escape them with `\`: `San Francisco\, CA`.

## Date filters

<Note>
  Filter suggestions are limited to 2,000 rows.
</Note>

Date filtering offers several filter options, including:

* Absolute date filtering, such as `2022`, `2023-01-01`, `2021-Q4`
* Relative date filtering, such as `after 7 complete days ago`, `1 year ago`

At times, filtering may require using both absolute and relative dates, for example `first ten days of 2023` or `100 days ago for 10 days`. For these situations, time for an interval duration offers more flexible time inputs:

* **The first input** should contain the **starting point**. This value should either be a date (`2023-01-01`) or a relative date (`10 days ago`). **Note**: `Ago` is required.
* **The second input** should contain the **duration**.

Check out the following examples to see how it all comes together:

```
# First ten days of 2023
[2023][10 days]
# 100 days ago for 10 days 
[100 complete days ago][10 days]
# 1 hour ago for 2000 milliseconds
[1 hour ago][2000 milliseconds]
```

### Interval timeframe units

Intervals can accept any timeframe unit:

| Interval type | Supported units                                                                |
| ------------- | ------------------------------------------------------------------------------ |
| day           | `day`, `days`, `complete day`, `complete days`                                 |
| week          | `week`, `weeks`, `complete week`, `complete weeks`                             |
| month         | `month`, `months`, `complete month`, `complete months`                         |
| quarter       | `quarter`, `quarters`, `complete quarter`, `complete quarters`                 |
| year          | `year`, `years`, `complete year`, `complete years`                             |
| millisecond   | `millisecond`, `milliseconds`, `complete millisecond`, `complete milliseconds` |
| second        | `second`, `seconds`, `complete second`, `complete seconds`                     |
| minute        | `minutes`, `complete minute`, `complete minutes`                               |
| hour          | `hour`, `hours`, `complete hour`, `complete hours`                             |

## Filtering by another query

With two or more tabs, one tab, or query, can be used as a filter in other queries. This is particularly useful for creating a dynamic subset of information in one query and a deep dive into the results on another tab.

For example, you want to understand the brands your top customers are purchasing. To do this, you would:

1. In a workbook, create a tab with the definition of a top customer.

2. Create a new tab.

3. In the new tab, add the dimensions and measures you want to analyze.

4. In the field picker, locate a dimension used in the top customer definition tab.

5. On the dimension, click the **options menu** (three dots) and select **Filter**.

6. Select **Is from another query**.

7. In the modal that displays, select the tab and dimension you want to filter by:

   <img src="https://mintcdn.com/omni-e7402367/UAlPtpzOyrORJCGb/images/docs/querying-and-sql/assets/images/filter_by_query_3-90913dbeaf8d26c7a28eaeb37c2043b1.png?fit=max&auto=format&n=UAlPtpzOyrORJCGb&q=85&s=db9e59aa2daf8bec72b25a859485c406" alt="" width="810" height="568" data-path="images/docs/querying-and-sql/assets/images/filter_by_query_3-90913dbeaf8d26c7a28eaeb37c2043b1.png" />

This will filter the tab results by the selected subset. In SQL, this generates `WHERE` clauses that look like `WHERE IN (SELECT...)` where the `SELECT` clause is the filtering query.

<Check>
  You can also use this approach to filter **out** data. To do this, select **Is not from another query** in the **Filter** menu or the [`field_name_not_in_query` filter parameter](/modeling/filters/operators/field-name-not-in-query).
</Check>

## Filtering by multiple conditions

You can filter a field by multiple conditions (e.g. `Date is in the past 30 days OR date is null`) by clicking **Add Condition** in the filter modal. Then, select if you want **All** or **Any** of the conditions to apply to the query.

## Filter suggestions

Filter suggestions are populated by running a sql query to return unique values for the field being filtered on, in the context of the Topic it is in, with the exception being if any of the following parameters are in use: [suggest\_from](/modeling/dimensions/parameters/suggest-from-field), [suggest\_from\_topic](/modeling/dimensions/parameters/suggest-from-topic), or [suggestion\_list](/modeling/dimensions/parameters/suggestion-list).

The general format is:

```sql theme={null}
  SELECT field_filter_is_based_on
    FROM table
GROUP BY 1
   LIMIT 2000
```

Depending on the specifics of the model (such as if this field is in a table other than the base view of a Topic) you may see the relevant JOIN or WHERE clause statements in the suggestion query.

The limit of 2000 is not configurable.

### Refreshing filter suggestions

In rare circumstances, filter suggestions may be cached in a stale state. To enable the refresh option:

* **Mac** - Hold `Command + Shift`
* **Windows** - Hold `Windows + Shift`

**Note**: The refresh option only clears suggestions for the specific query, not all filter suggestions. More troubleshooting tips can be found [here](https://community.omni.co/t/why-doesnt-my-filter-show-all-possible-values-as-suggestions/54)

<img src="https://mintcdn.com/omni-e7402367/UAlPtpzOyrORJCGb/images/docs/querying-and-sql/assets/images/refresh-suggest-3e2d9a1bfaf10fe2a8cada9a3cbc922b.png?fit=max&auto=format&n=UAlPtpzOyrORJCGb&q=85&s=3826ed978b55138f7bc3a01d7bb9d424" alt="" width="428" height="324" data-path="images/docs/querying-and-sql/assets/images/refresh-suggest-3e2d9a1bfaf10fe2a8cada9a3cbc922b.png" />

## Adding dashboard filters to workbook queries

<Note>
  This feature is not available in raw SQL mode or on read-only/linked tabs.
</Note>

When editing a workbook tab that's backed by a dashboard with filters, you can quickly add dashboard-level filters to your workbook query using the **Filters from dashboard** dropdown.

Click the **Filters from dashboard** dropdown located in the query tab's filter bar to see applicable dashboard filters. Values and settings from the dashboard are preserved when a filter is added.

If you don't see a filter you expect to, keep in mind that Omni excludes:

* Filters already present on the query
* Filters whose fields are covered by existing controls
* Hidden filters
* Cross-topic filters (filters that don't match the tab's topic)
* Dashboard controls
