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
| Argument | Description |
|---|---|
measure | A measure of a model the SELECT reads, such as orders.sum__quantity. |
modifier | Optional. CLEAR(), one REMOVE(...), one or more SET(...), or SET_CUSTOM(...). |
Returns
The measure’s value for each row.
Usage notes
- Each
EVALtakes one kind of modifier. SeveralSETs apply in order, and each one sees the context the one before it set. Any other mix, such asREMOVEwithSET, is refused. - The measure’s definition still applies under every modifier. The
WHEREof the model that declares it, its required filters and its joins stay in force. - A model that reads this SELECT sees an
EVALcolumn as a dimension. To pass a measure on as a measure, select it as it is, such asorders.sum__quantity. - An
ASalias does not rename anEVAL. TwoEVALs of one measure in one SELECT have the same name, and the compile fails. Declare the second one, such asMEASURE('all_units', EVAL(orders.sum__quantity, CLEAR())). - An
EVALof 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 ordersGROUP BY orders.channelORDER BY 1| Channel | Units |
|---|---|
| 2,383 | |
| paid | 2,292 |
| store | 2,330 |
| web | 2,149 |
See also
- Change a measure’s context
- Pass through, evaluate or declare
- Other functions in EVAL and its modifiers:
CLEAR,REMOVE,SET,SET_CUSTOM,CURRENT