exact_period
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 within a custom period, it can be used to compare how a metric performs in a specific period compared to another period.
Syntax
exact_period(metric, time_dimension, time_range)
exact_period(orders.total_orders, orders.created_at, @2022-07-01 - 2022-09-01)
// with pipe
orders.total_orders | exact_period(orders.created_at, @2022-07-01 - 2022-09-01)
Input
metric
: A metric that you want to calculate within a custom periodtime_dimension
: A pre-defined datetime/date dimension that is used for shiftingtime_range
: A datetime literal that specifies an exact time range for shifting. E.g.@2022-04-01
,@2022
,@(last 2 weeks)
(see Datetime Literals for more details)
Output
The same metric calculated in a custom period.
Combine with dimension
Categorical dimension
When combining with categorical dimension, exact_period()
is similar to the where()
function. The difference is that exact_period()
will override any applied time filter, while where()
will add the new filter with using AND
operator logic.
Time dimension
Similar to Dashboard custom period comparison, when combining with another time dimension, exact_period()
will add the equivalent period specified in time_range
argument alongside to the other measures of that time dimension
For more examples on the differences between the two use cases, please check the Sample Usages section below.
Sample Usages
Use filtering in reporting to apply your time condition, then use exact_period()
to compare it with.
For all the examples below, the filter on reporting is set as orders.created_at last 3 months
Let’s say we want to compare total orders from an arbitrary period to the back-to-school season (from July to September).
First, creating measure count(orders.id)
with custom period from 2022-07-01
to 2022-09-01
count(orders.id) | exact_period(orders.created_at, @2022-07-01 - 2022-09-01)
On time-series dimension
Compare week-by-week the last 3 months of count orders to the back-to-school season in
Plot as line chart
On categorical dimension
Compare the last 3 months of count orders to the back-to-school season for each continent
Plot as bar chart