When would you use this?
- The CEO asks for a revenue growth chart showing this year versus last year by month
- and next quarter you want the same chart to automatically include Q3 data.
- A regional analyst wants to compare Seoul’s Q2 revenue to Q2 the prior year, without anyone having to manually export and join two date-range queries.
- Your executive dashboard needs a YoY percentage change KPI that works whether the user slices by day, month, quarter, or year - without separate metric definitions.
- A data team wants to define prior year revenue once as a governed metric so every dashboard uses the same definition rather than each building its own date offset logic.
What this recipe builds
Three metrics usingTIME_METRIC with the offset parameter: current-period revenue,
prior-year revenue, and a YoY percentage change derived from the two.
Prerequisites
Same time spine setup as the active customers recipe -date entity marked is_time_spine: yes.
Steps
1
Revenue (current period)
Revenue anchored to the time spine. This is the baseline for the YoY comparison.
It adapts to any grain the user selects.
- SQL
- YAML
2
Revenue (prior year)
Revenue shifted one year back using
offset => '1 year'. Each spine row shows
revenue from the same period twelve months earlier - same day, same month, same
quarter, depending on the user’s grain.- SQL
- YAML
3
Revenue YoY change percentage
Year-over-year growth rate. Positive values mean growth; negative values mean
decline.
- SQL
- YAML
Sample output
Sliced by month
Each row inrevenue_prior_year shows the revenue from the same month one year
earlier - January 2022 shows January 2021, February 2022 shows February 2021,
and so on.
Sliced by week
Each row shows the revenue from the same calendar week one year earlier - week starting Jan 3, 2022 is compared to the week starting Jan 4, 2021.Related reading
- Time metrics - reference for
TIME_METRICand theoffsetargument - Active customers & stickiness - introduces
TIME_METRICand the time spine setup