Skip to main content

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.

FunctionSyntaxPurpose
wherewhere(measure, condition)Apply condition(s) to original measure

Relationship Functions

Relationship Functions change the default relationships defined at dataset level for a specific metric.

FunctionSyntaxPurpose
with_relationshipswith_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.

FunctionSyntaxPurpose
evaleval(measure, metric_function)Apply metric function(s) to modify the original measure
exclude, exclude_grains, of_allexclude_grains(measure, model, dim)

of_all(expression, model, dim)
Exclude dimension(s) from a measure calculation
exact_grainsexact_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.

FunctionSyntaxPurpose
exact_periodexact_period(measure, time_dimension, time_range) Returns the same measure calculated in a custom period.
relative_periodrelative_period(measure, time_dimension, interval)Returns the same measure calculated with shifting time
running_totalrunning_total(measure, running_dimension)Returns a running total measure
rankrank(order, partition)Returns a rank measure
period_to_dateperiod_to_date(measure, date_part, date_dimension)Returns a cumulative period to date measure
trailing_periodtrailing_period(measure, date_dimension, periods)Returns a trailing period measure

Let us know what you think about this document :)