Kater SQL Functions EVAL and its modifiers
SET
Replaces one dimension's grouping and filter with one value.
Family: EVAL and its modifiers
Write it inside EVAL, or after the measure in VALUE_FOR, TOTAL or SHARE_OF_TOTAL.
Syntax
EVAL(measure, SET(dimension = value) [, SET(dimension = value) ...])Arguments
| Argument | Description |
|---|---|
dimension = value | The dimension on the left, and its value on the right, such as orders.channel = 'web'. NULL selects the rows where the dimension is null. |
Returns
The measure for that value of the dimension, on each row of the result.
Usage notes
- The rows that the SELECT returns do not change. Only this one value does.
- Several
SETs apply in order, and each one sees the context the one before it set. - Inside
EVAL, the value can readCURRENT, such asCURRENT(orders.order_month) - 1. InVALUE_FOR,TOTALandSHARE_OF_TOTAL, the value must be a constant. - The measure’s own definition still applies.
Example
This Sandbox query reads the sample shop’s orders. The table shows the rows that Kater gave.
SELECT orders.region AS "Region", EVAL(orders.sum__quantity) AS "Units", MEASURE('web_units', EVAL(orders.sum__quantity, SET(orders.channel = 'web'))) AS "Web Units"FROM kater_dataset.orders AS ordersWHERE KATER__IS_NOT_NULL(orders.region)GROUP BY orders.regionORDER BY 1| Region | Units | Web Units |
|---|---|---|
| AMER | 2,179 | 495 |
| APAC | 2,097 | 520 |
| EMEA | 2,421 | 577 |
| LATAM | 2,260 | 504 |
See also
- Change a measure’s context
- Pass through, evaluate or declare
- Other functions in EVAL and its modifiers:
EVAL,CLEAR,REMOVE,SET_CUSTOM,CURRENT