Define an aggregation
Create a shared metric from model properties.
An aggregation calculates a metric across rows, such as total revenue or the number of orders. Define it on a model when reports should reuse the same calculation.
Before you start
You need Builder, Admin, or a custom role with model editing access. The model must have the properties required by the metric. Decide what the metric counts, which rows it includes, and how it handles repeated values.
Create the metric
- Open the model in Models.
- In the aggregations list, select New aggregation or the add button beside the list.
- Enter a Name and select Create.
- Choose Aggregation as the definition type.
- Select Property and the aggregation operation.
- Add a description and any required filters.
- Select Generate preview to inspect the result.
- Select the model's Save button and check validation.
| Operation | Result |
|---|---|
| Count | Counts non-null values of the selected property. |
| Count Distinct | Counts different non-null values. |
| Sum | Adds numeric values. |
| Average | Calculates the numeric mean. |
| Min | Returns the lowest numeric value. |
| Max | Returns the highest numeric value. |
The editor enables the numeric operations only for numeric properties.
For an Orders metric, select order_id and Count Distinct.
For Net revenue, select net_revenue and Sum.
Use filters or a formula
Aggregation filters restrict the rows counted by that metric. For example, a paid-orders metric can include only rows whose status is paid. Check the metric alongside an unfiltered count to confirm the difference.
For a formula, choose Custom Formula and edit the formula. Follow the SQL dialect shown in the editor. Use the field picker to insert valid property or aggregation references.
Verify the metric
Build an explore with the metric alone, then add a grouping property, such as sales channel. Compare the result with a small set of known rows. If the operation is unavailable, check the property's type. If the formula fails validation, check its references and dialect.
A custom aggregation created inside one explore stays local to that explore. Define shared metrics here when several documents need the same rule.
Use the aggregation's Description for its summary and model context for interpretation rules and exceptions.