> ## 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.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.omni.co/feedback

```json
{
  "path": "/modeling/filters/index",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

# Filter syntax

> Write and structure filter definitions in your Omni model YAML using operators, negation, and compound filter expressions.

<Tip>
  **Build your filters faster by starting in the workbook!** Add a filter to a query, save it as a query view, and open the query view editor to check out the underlying YAML. This can help you get the right structure and ensure the results are correct.
</Tip>

Omni's filter syntax is built to mirror how filtering works in the Omni app, whether you're in a workbook or a dashboard. Use the following tabs to see how filters are defined in Omni YAML:

<Tabs>
  <Tab title="Topics" icon="book">
    Use [`always_where_filters`](/modeling/topics/parameters/always-where-filters) and [`default_filters`](/modeling/topics/parameters/default-filters) to add filters to topics. For example:

    ```yaml title="Topic default_filters" theme={null}
    default_filters:
      users.status:
        is: active
    ```
  </Tab>

  <Tab title="Query views" icon="question">
    Query views, which are built from workbook queries, contain a `query` property. The `query.filters` property lists the filters applied to the view's underlying query:

    ```yaml title="Query view filters" highlight={6-12} theme={null}
    query:
      fields:
        users.id: id
        order_items.sale_price_sum: sales
      base_view: order_items
      filters:
        users.age_bin:
          is: []
        users.created_at:
          is: "2021"
        order_items.created_at:
          time_for_duration: [ 30 complete days ago, 30 days ]
    ```
  </Tab>

  <Tab title="Measures" icon="ruler">
    Add filters directly to measures with the [`filters`](/modeling/measures/parameters/filters) property:

    ```yaml title="Filtered measure" highlight={4-6} theme={null}
    measures:
      aggregate_type: count
      count:
        filters:
          status:
            is: active
    ```
  </Tab>
</Tabs>

## Operators

Operators allow you to specify the type of filter you want to apply. Operators consist of a string, appended with a colon (`:`): `<operator>:`. [Filter values](#filter-values) should follow the colon.

For example:

```yaml theme={null}
day_of_week: <filter_value>
less_than: <filter_value>
contains: <filter_value>
```

### Types

Omni supports several types of operators, such as conditional, time, numeric, and text. Refer to the [Filter operators reference](/modeling/filters/operators) for a complete list of operators.

### Negation

Prefix a filter operator with `not_` to create a negation. For example, `day_of_week` would become `not_day_of_week`.

<Warning>
  The `not_` prefix isn't compatible with the following operators:

  * [`is`](/modeling/filters/operators/is) - Use the [`not`](/modeling/filters/operators/not) operator instead
  * [`and`](/modeling/filters/operators/and)
  * [`or`](/modeling/filters/operators/or)
</Warning>

## Filter values

Include filter values after the operator and the colon. Values should be unquoted; quotes will be removed upon saving.

```yaml title="Filter values should be unquoted" theme={null}
starts_with: Blob
```

### Strings and dates

Provide strings and dates as unquoted values:

```yaml title="String value" theme={null}
contains: Blob
```

```yaml title="Date value" theme={null}
before: 2025-01-01
```

### Booleans

Omni supports both two-state (`true` / `false`) and three-state (`true` / `false` / `null`) boolean logic. The special boolean argument `falsey` represents both `false` and `null` and can be used in filters like any other field value.

```yaml title="Counts if error = false or null" theme={null}
non_error_count:
  aggregate_type: count
  filters:
    is_error:
      is: falsey
```

```yaml title="Count if error = false" theme={null}
non_error_count:
  aggregate_type: count
  filters:
    is_error:
      is: false
```

### Arrays / lists

Arrays are constructed using square brackets (`[]`). Add the filter values inside the brackets, for example:

```yaml title="Array of numbers" theme={null}
[ 1, 2, 3 ]
```

```yaml title="Array of strings" theme={null}
[ California, Oregon, Washington ]
```
