Metric Functions
Metric functions transform an input metric expression into another metric expression, usually through modifying the context of that input expression. These functions are broken down into these categories:
Condition Functions
Condition Functions restrict the values to be aggregated for a metric based on specified conditions.
Function | Syntax | Purpose |
---|---|---|
where | where(measure, condition) | Apply condition(s) to original measure |
Relationship Functions
Relationship Functions change the default relationships defined at dataset level for a specific metric.
Function | Syntax | Purpose |
---|---|---|
with_relationships | with_relationships(measure, relationship) | Specifies what existing relationship(s) to used for this measure calculation |
LOD Functions
LOD Functions modify the Level of Detail of a metric to serve specific analytics needs.
Function | Syntax | Purpose |
---|---|---|
eval | eval(measure, metric_function) | Apply metric function(s) to modify the original measure |
exclude, exclude_grains, of_all | exclude_grains(measure, model, dim) of_all(expression, model, dim) | Exclude dimension(s) from a measure calculation |
exact_grains | exact_grains(measure, model, dim) | Choose exact dimension(s) for this measure calculation |
Window Functions
Window Functions provide ways to modify an existing metric to support analytics use cases that require accumulation or comparisons across a subset of data of a given query. These are analogous to SQL window functions.
Function | Syntax | Purpose |
---|---|---|
exact_period | exact_period(measure, time_dimension, time_range) | Returns the same measure calculated in a custom period. |
relative_period | relative_period(measure, time_dimension, interval) | Returns the same measure calculated with shifting time |
running_total | running_total(measure, running_dimension) | Returns a running total measure |
rank | rank(order, partition) | Returns a rank measure |
period_to_date | period_to_date(measure, date_part, date_dimension) | Returns a cumulative period to date measure |
trailing_period | trailing_period(measure, date_dimension, periods) | Returns a trailing period measure |