sum of revenue)
or reference other measures to create compound metrics (like revenue / count).
See the measures reference for the full list of parameters
and configuration options.
Defining measures
A measure specifies the SQL expression to aggregate and the aggregation type:Filtered measures
You can apply filters to a measure to create conditional aggregations. Only rows matching the filter are included:completed_count is queried, Cube generates SQL with a CASE expression:
Calculated measures
Calculated measures perform calculations on other measures using SQL functions and operators. They provide a way to decompose complex metrics (e.g., ratios or percents) into formulas involving simpler measures.Referencing measures in the same cube
Referencing measures from other cubes
If cubes are joined, you can reference measures across cubes. Cube generates the necessary joins automatically:Multi-stage measures
Multi-stage measures are calculated in two or more stages, enabling calculations on already-aggregated data. Each stage results in one or more CTEs in the generated SQL query.Rolling windows
Rolling window measures calculate metrics over a moving window of time, such as cumulative counts or moving averages. Use therolling_window parameter:
Period-to-date
Period-to-date measures analyze data from the start of a period to the current date — year-to-date (YTD), quarter-to-date (QTD), or month-to-date (MTD):Time shift
Time-shift measures calculate the value of another measure at a different point in time, typically for period-over-period comparisons like year-over-year growth. Use thetime_shift parameter:
Percent of total (fixed dimension)
Use thegroup_by parameter to fix the inner aggregation to
specific dimensions, enabling percent-of-total calculations:
Nested aggregates
Use theadd_group_by parameter to compute an aggregate
of an aggregate, e.g., the average of per-customer averages:
Ranking
Use thereduce_by parameter to rank items within groups:
Conditional measures
Conditional measures depend on the value of a dimension, using thecase parameter with switch dimensions:
Formatting
Use theformat parameter to control how measures are displayed:
Next steps
- See the measures reference for all parameters
- Learn about dimensions for grouping and filtering
- Explore pre-aggregations to accelerate measure queries
- See the period-over-period recipe for advanced time comparisons