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

# drill_queries

> Defines multiple drill query options, with full control over the underlying query.

<Note>
  If a measure has `drill_queries` and `drill_fields` defined, `drill_queries` will override `drill_fields`.
</Note>

Drill queries appear as options when you click to drill on a measure in a document. Providing drill queries is more flexible than a [`drill_fields`](/modeling/measures/parameters/drill-fields) set, as they allow you to specify the underlying query to drill. This includes changes such as limits, sorts, filters, and base views.

Filters specified in a drill query are additive, meaning they will be applied in addition to any filters from the main query and the associated dimension values of the cell being drilled.

If you want to reference fields from multiple views, ensure that a relationship exists between your base view and the other referenced views so that your drill down will render as expected. To get the structure + syntax of a query, build a query in a workbook and open up the [inspector](/analyze-explore/workbook-inspector) and scroll down to the "Query Structure" settings.

## Syntax

```yaml theme={null}
<measure_name>:
  drill_queries:
    <Drill Query Label>:
      fields: [<field1>, <field2>, ...]
      base_view: <view_name>
      filters: {...}
      sorts: [...]
      limit: <number>
```

## Properties

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

  <Expandable title="measure_name properties" defaultOpen="true">
    <ParamField path="drill_queries" type="object">
      An object containing one or more drill query definitions, each with a human-readable label as the key.

      <Expandable title="drill_queries properties" defaultOpen="true">
        <ParamField path="Drill Query Label" type="object[]">
          An object containing a drill query definition. Underscores are not required for drill query labels.

          <Expandable title="Drill Query Label properties" defaultOpen="true">
            <ParamField path="fields" type="string[]">
              An array of field names to include in the drill query.
            </ParamField>

            <ParamField path="base_view" type="string">
              The table that will act as the `FROM` clause of the query.
            </ParamField>

            <ParamField path="filters" type="object">
              Optional filters to apply to the drill query using [filter syntax](/modeling/filters).
            </ParamField>

            <ParamField path="sorts" type="string[]">
              Optional sort specifications. **Note**: Full scoping for fields is required.
            </ParamField>

            <ParamField path="limit" type="number">
              Optional row limit for the drill query.
            </ParamField>
          </Expandable>
        </ParamField>
      </Expandable>
    </ParamField>
  </Expandable>
</ParamField>

## Examples

```yaml title="Multiple drill options" theme={null}
my_fun_measure:
  sql: ${field_we_aggregate}
  aggregate_type: sum
  drill_queries:
    First Drill for Top 10:
      fields:
        [
        field_1,
        field_2
        ]
      base_view: view_name_1
      filters:
        is_top_10:
          is: true
      sorts:
        - field: view_name_1.field_1
        - field: view_name_1.field_2
          desc: true
    Customer Details:
      fields:
        [
        customer_name,
        customer_email,
        registration_date
        ]
      base_view: customers
      limit: 20
      sorts:
        - field: customers.registration_date
          desc: true
```
