Kater SQL Functions Calendar comparisons
KATER__PERCENT_CHANGE
The change from the baseline to the current value, as a share of the baseline.
Family: Calendar comparisons
Syntax
KATER__PERCENT_CHANGE(current, baseline)Arguments
| Argument | Description |
|---|---|
current | The current value, such as EVAL(orders.sum__amount). |
baseline | The value to compare with, such as KATER__PREVIOUS_PERIOD(orders.sum__amount). An expression. |
Returns
A fraction, such as 0.25 for 25%. The field menu writes @format percent(1) beside it, so it shows as a percentage. NULL where the baseline is 0 or empty.
Usage notes
- It divides by the absolute value of the baseline, so a change from -10 to -5 is +50%.
- It takes any two numbers, not only a calendar comparison.
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( 'percent_change__sum__quantity', KATER__PERCENT_CHANGE(EVAL(orders.sum__quantity), KATER__PREVIOUS_PERIOD(orders.sum__quantity, by => KATER__MONTH(orders.order_date))) ) AS "Change from Month Before" /* @format percent(1) */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 | Change from Month Before |
|---|---|---|
| 2026-05-01 | 441 | 17.9% |
| 2026-06-01 | 403 | -8.6% |
| 2026-07-01 | 438 | 8.7% |
| 2026-08-01 | 454 | 3.7% |
| 2026-09-01 | 442 | -2.6% |