Skip to main content
On this page

Kater SQL Functions EVAL and its modifiers

EVAL

Works out a measure on each row, at the SELECT's grouping and with its filters.

Family: EVAL and its modifiers

A modifier changes that context for this one value.

Syntax

EVAL(measure [, modifier])

Arguments

ArgumentDescription
measureA measure of a model the SELECT reads, such as orders.sum__quantity.
modifierOptional. CLEAR(), one REMOVE(...), one or more SET(...), or SET_CUSTOM(...).

Returns

The measure’s value for each row.

Usage notes

  • Each EVAL takes one kind of modifier. Several SETs apply in order, and each one sees the context the one before it set. Any other mix, such as REMOVE with SET, is refused.
  • The measure’s definition still applies under every modifier. The WHERE of the model that declares it, its required filters and its joins stay in force.
  • A model that reads this SELECT sees an EVAL column as a dimension. To pass a measure on as a measure, select it as it is, such as orders.sum__quantity.
  • An AS alias does not rename an EVAL. Two EVALs of one measure in one SELECT have the same name, and the compile fails. Declare the second one, such as MEASURE('all_units', EVAL(orders.sum__quantity, CLEAR())).
  • An EVAL of a dimension is the same dimension. A dimension takes no modifiers.

Example

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

SELECT
orders.channel AS "Channel",
EVAL(orders.sum__quantity) AS "Units"
FROM kater_dataset.orders AS orders
GROUP BY
orders.channel
ORDER BY
1
ChannelUnits
email2,383
paid2,292
store2,330
web2,149

See also