Kater SQL Functions Calendar comparisons
KATER__SAME_PERIOD_LAST_YEAR
The measure for the same period one year earlier, such as March 2025 for March 2026.
Family: Calendar comparisons
Syntax
KATER__SAME_PERIOD_LAST_YEAR(measure [, by => date] [, coverage => 'matching_elapsed' | 'full_period'])Arguments
Required
| Argument | Description |
|---|---|
measure | The measure to compare, written bare, without EVAL. |
Optional
| Argument | Description |
|---|---|
by | The date axis to compare along, such as KATER__MONTH(orders.order_date). Left out, it is the one date in GROUP BY. An expression. |
coverage | What the earlier period covers when the query filters the date axis. 'matching_elapsed' takes the same dates, moved back. 'full_period' takes whole periods. One of 'matching_elapsed', 'full_period'. It is 'matching_elapsed' when left out. |
Returns
A number. The field menu writes the @format of the field it reads beside it, or @format number(2) where that field has none and can have decimals.
Usage notes
- It works the measure out again over the source rows of the earlier period. It does not read an earlier row of the result, so a period with no row still has a value.
- The axis is a date at a grain of day, month or quarter.
- On a day axis, a day with no match a year earlier, such as 29 February, gives NULL.
- A date filter on the axis needs fixed dates at both ends. A moving end, such as
CURRENT_DATE, is refused. - For the change, subtract the call from
EVAL(measure). For the percent change, giveEVAL(measure)and the call toKATER__PERCENT_CHANGE. - In a query, declare it with
CUSTOM_CALCULATION. As aMEASURE, it needsby.
Example
This Sandbox query reads the sample shop’s orders. The table shows the rows that Kater gave.
SELECT KATER__MONTH(orders.order_date) AS "Order Month", EVAL(orders.sum__quantity) AS "Units", CUSTOM_CALCULATION( 'same_period_last_year__sum__quantity', KATER__SAME_PERIOD_LAST_YEAR(orders.sum__quantity, by => KATER__MONTH(orders.order_date)) ) AS "Units Year Before"FROM kater_dataset.orders AS ordersWHERE KATER__IS_BETWEEN(orders.order_date, DATE '2026-05-01', DATE '2026-09-30')GROUP BY KATER__MONTH(orders.order_date)ORDER BY 1| Order Month | Units | Units Year Before |
|---|---|---|
| 2026-05-01 | 441 | 442 |
| 2026-06-01 | 403 | 426 |
| 2026-07-01 | 438 | 411 |
| 2026-08-01 | 454 | 454 |
| 2026-09-01 | 442 | 428 |