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

> Applies filters to a measure for filtered aggregations.

Filtered measures can be built using aggregation alongside a dimension filter. When building measures in the UI, filters may only be available for standard measures and quick-aggregates. For measures built with custom SQL logic, best practice is to define filters in the YAML definition.

See full page on filter syntax [here](/modeling/filters).

## Syntax

```yaml theme={null}
<measure_name>:
  aggregate_type: <type>
  filters:
    <field_name>:
      <filter_condition>: <value>
```

## Properties

<ParamField path="measure_name" type="object[]">
  The name of the measure.

  <Expandable title="measure_name properties" defaultOpen="true">
    <ParamField path="filters" type="object">
      A mapping of field names to their filter conditions using [filter syntax](/modeling/filters). Multiple filters can be added, and multiple values for a given filter can be added using array syntax.
    </ParamField>
  </Expandable>
</ParamField>

## Examples

```yaml title="Count with multiple filters" theme={null}
count_california_seniors:
  aggregate_type: count
  filters:
    age:
      greater_than_or_equal_to: 65
    state:
      is: California
```

```yaml title="Filter with array values" theme={null}
count_ny_or_nj:
  aggregate_type: count
  filters:
    state:
      is: [New York, New Jersey]
```

```yaml title="Filter using modeled boolean field" theme={null}
### note filtered measures can point to raw columns or modeled fields
dimensions:
  is_big:
    sql: ${employee_count} > 100000
measures:
  count_large:
    aggregate_type: count
    filters:
      is_big:
        is: true
```

```yaml title="Complex logic with boolean dimension" theme={null}
complex_dimension_example:
  sql: ${state} = 'California' OR ${age} > 65
count_complex_logic:
  aggregate_type: count
  filters:
    complex_dimension_example:
      is: true
```

```yaml title="Filter by query (top 10 users)" theme={null}
count_top_10_users:
  format: NUMBER
  aggregate_type: count
  filters:
    id:
      field_name_in_query: order_items.user_id
      query_structure:
        fields: [ order_items.user_id, order_items.sale_price_sum ]
        base_view: order_items
        limit: 10
        sorts:
          - field: order_items.sale_price_sum
            desc: true
        topic: order_items
```
