> ## 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/measures/parameters/aggregate-type",
  "feedback": "Description of the issue"
}
```

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

</AgentInstructions>

# aggregate_type

> Defines the aggregation method for an underlying dimension.

<Tip>
  **Don't see an aggregate you want**? Use [SQL](/modeling/measures/parameters/sql) to define the aggregate instead, for example: `sql: MEDIAN(${orders.price}`
</Tip>

## Syntax

```yaml theme={null}
<measure_name>:
  sql: ${<view_name>.<field_name>}
  aggregate_type: <aggregation_method>
```

## Properties

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

  <Expandable title="measure_name properties" defaultOpen="true">
    <ParamField path="sql" type="string">
      The SQL used to create the measure. Specify fields as `view_name.field_name`.
    </ParamField>

    <ParamField path="aggregate_type" type="string">
      The aggregation method to apply to the measure. Must be one of:

      | Aggregate type           | Description                                                                                                                                      |
      | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
      | `sum`                    | Sum of values                                                                                                                                    |
      | `count`                  | Count of rows                                                                                                                                    |
      | `count_distinct`         | Count of distinct values                                                                                                                         |
      | `average`                | Average of values                                                                                                                                |
      | `min`                    | Minimum value                                                                                                                                    |
      | `max`                    | Maximum value                                                                                                                                    |
      | `median`                 | Median value                                                                                                                                     |
      | `list`                   | Concatenated list of values                                                                                                                      |
      | `percentile`             | Percentile calculation. Requires an additional `percentile` parameter on the measure. Refer to the [Examples](#examples) section for an example. |
      | `sum_distinct_on`        | Sum with deduplication on a custom key. Requires [`custom_primary_key_sql`](/modeling/measures/parameters/custom-primary-key-sql).               |
      | `average_distinct_on`    | Average with deduplication on a custom key                                                                                                       |
      | `median_distinct_on`     | Median with deduplication on a custom key                                                                                                        |
      | `percentile_distinct_on` | Percentile with deduplication on a custom key                                                                                                    |
    </ParamField>
  </Expandable>
</ParamField>

## Examples

```yaml title="Sum aggregation" theme={null}
total_revenue:
  sql: ${orders.sales_price}
  aggregate_type: sum
```

```yaml title="Measure with division" theme={null}
revenue_per_order:
  sql: ${orders.total_revenue} / ${orders.count}
```

```yaml title="Percentile aggregation" theme={null}
perc_75_age:
  sql: ${users.age}
  aggregate_type: percentile
  percentile: 75
```

```yaml title="Sum distinct on" theme={null}
sum_distinct_example:
  sql: price
  aggregate_type: sum_distinct_on
  custom_primary_key_sql: ${id}
```
