> ## 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/operators/cancel-query-filter",
  "feedback": "Description of the issue"
}
```

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

</AgentInstructions>

# cancel_query_filter

> Creates a measure that ignores the value of a filter in the user query in favor of the filter on the measure itself.

Creates a measure that ignores the value of a filter in the user query in favor of the filter on the measure itself. This creates measures that maintain their specific filter criteria regardless of what filters the user applies in the query.

<Note>
  This is an advanced filter property that can be added as an argument to any other filter on a measure. It's commonly used with [`date_offset_from_query`](/modeling/filters/operators/date-offset-from-query) for period-over-period comparisons, but can be used with any filter.
</Note>

## Syntax

```yaml theme={null}
measures:
  <measure_name>:
    aggregate_type: <type>
    filters:
      <field>:
        <filter_operator>: <value>
        cancel_query_filter: true
```

## Properties

<ParamField path="field" type="string" required>
  The field to filter on, specified in the format `view_name.field_name`. Can be a time, numeric, or string field.
</ParamField>

<ParamField path="filter_operator" type="varies" required>
  Any standard filter operator (e.g., [`is`](/modeling/filters/operators/is), [`not`](/modeling/filters/operators/not), [`greater_than`](/modeling/filters/operators/greater-than), [`date_offset_from_query`](/modeling/filters/operators/date-offset-from-query), etc.) with its corresponding value.
</ParamField>

<ParamField path="cancel_query_filter" type="boolean" required>
  If `true`, the measure will ignore a query's filter value. Instead, the measure will use the filter defined on the measure itself.
</ParamField>

## Examples

For this example, you're querying a dataset that has a `state: New York` filter applied. Using the following `compare_to_users_in_california` measure in your query would allow you to see the count of users for `California` without changing the filter in your query.

If `cancel_query_filter` were not applied, you would receive zero results - this is because the measure would filter for users in `California` within a query filtered for `New York`.

```yaml title="Ignore filters on state" theme={null}
measures:
  compare_to_users_in_california:
    aggregate_type: count
    filters:
      state:
        is: California
        cancel_query_filter: true
```

### Ignore filters on specified fields

The following example demonstrates how to create a measure that ignores any query filters on two specified fields. Setting the filter to `is: ""` for both `created_at` and `state` tells the measure to ignore any filter on these fields, allowing comparison to all-time totals regardless of any filters applied to the query.

```yaml title="Ignore all filters on created_at and state" theme={null}
measures:
  users_in_all_states_all_time:
    aggregate_type: count
    filters:
      created_at:
        is: ""
        cancel_query_filter: true
      state:
        is: ""
        cancel_query_filter: true
```

```yaml theme={null}
signups_two_years_ago:
  aggregate_type: count
  filters:
    created_at:
      date_offset_from_query: 2 years
      cancel_query_filter: true
```

### Ignore specific filters in a level of detail field

You can use `cancel_query_filter` within the `filters` parameter of a `level_of_detail` calculation to selectively ignore specific global filters for that LoD only. This allows you to keep some global filters while dropping others, rather than using `cancel_query_filters: true` which ignores all global filters.

```yaml title="Dimension with selective filter cancellation" theme={null}
arr_balance_by_logo:
  sql: ${accounts.arr_cumulative}
  level_of_detail:
    aggregate_type: max
    fixed: [logo, date]
    filters:
      date:
        is: ""
        cancel_query_filter: true  # Drops global date filter, keeps other filters
```

```yaml title="Measure with selective filter cancellation" theme={null}
measures:
  california_revenue:
    aggregate_type: sum
    sql: ${revenue}
    level_of_detail:
      aggregate_type: sum
      fixed: [state]
      filters:
        state:
          is: California  # Replaces global state filter with California
          cancel_query_filter: true
```

This feature works on both [dimension `level_of_detail`](/modeling/dimensions/parameters/level-of-detail) and [measure `level_of_detail`](/modeling/measures/parameters/level-of-detail).
