relative_period
tip
Holistics has also supported Period Comparison on UI via Dashboard-level Period Comparison and widget-level Period Comparison which use exact_period()
and relative_period()
behind the scenes.
Definition
Calculates a metric in the active time-range shifted by a specified interval. The active time-range can be the time range specified in a filter (if no time dimension is active) or the time period in each row of a time dimension.
Syntax
relative_period(metric, time_dimension, time_interval)
Examples
relative_period(orders.total_orders, orders.created_at, interval(-1 month))
// with pipe
orders.total_orders | relative_period(orders.created_at, interval(-1 month))
Input
metric
: A metric that you want to calculate within a relative intervaltime_dimension
: A pre-defined datetime/date dimension that is used for shiftingtime_interval
: A relative interval for shifting from the time condition. E.g.interval(-1 month)
Output
The same metric calculated in the active time-range shifted by the specified interval.