Skip to main content
On this page

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

ArgumentDescription
currentThe current value, such as EVAL(orders.sum__amount).
baselineThe 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 orders
WHERE
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 MonthUnitsChange from Month Before
2026-05-0144117.9%
2026-06-01403-8.6%
2026-07-014388.7%
2026-08-014543.7%
2026-09-01442-2.6%

See also