Skip to main content
On this page

Kater SQL Functions EVAL and its modifiers

CURRENT

Gives a dimension's value on the row being worked out, inside a SET in an EVAL.

Family: EVAL and its modifiers

Use it to compare each row with another, such as the month before.

Syntax

EVAL(measure, SET(dimension = CURRENT(dimension) - n))

Arguments

ArgumentDescription
dimensionA dimension that the SELECT groups by or filters by, such as orders.order_month.

Returns

The dimension’s value on the row. It is null when the SELECT neither groups nor filters by the dimension.

Usage notes

  • On a date grain, a number counts periods of that grain. On a month, CURRENT(orders.order_month) - 1 is the month before. On a year, - 1 is the year before.
  • CURRENT works only inside SET in an EVAL. VALUE_FOR, TOTAL and SHARE_OF_TOTAL take constant values.

Example

This Sandbox query reads the sample shop’s orders. The table shows the rows that Kater gave.

SELECT
orders.order_month AS "Order Month",
EVAL(orders.sum__quantity) AS "Units",
MEASURE('units_month_before', EVAL(orders.sum__quantity, SET(orders.order_month = CURRENT(orders.order_month) - 1))) AS "Units the Month Before"
FROM kater_dataset.orders AS orders
WHERE
KATER__IS_ON_OR_AFTER(orders.order_month, DATE '2026-05-01')
GROUP BY
orders.order_month
ORDER BY
1
Order MonthUnitsUnits the Month Before
2026-05-01441374
2026-06-01403441
2026-07-01438403
2026-08-01454438
2026-09-01442454

The query starts in May, but May’s row still shows April’s units. SET replaces the filter on the month, so the month before counts.

See also