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 scene
Definition
Takes one measure and calculates it within a custom period. exact_period()
can be used to compare with the same measure in the reporting layer which has a time condition applied
Syntax
exact_period(measure, 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
measure
: A measure 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 measure calculated in a custom period.
Combine with dimension
Categorical dimension
Similar to other measures, when combining with categorical dimension, exact_period()
works by calculating the measure for each dimension and add to the result
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