Kater SQL Functions EVAL and its modifiers
SET_CUSTOM
Replaces all of an EVAL's grouping and filters with one condition of your own.
Family: EVAL and its modifiers
Write it inside EVAL.
Syntax
EVAL(measure, SET_CUSTOM(condition))Arguments
| Argument | Description |
|---|---|
condition | A condition that names at least one of the measure’s dimensions, such as orders.channel IN ('web', 'email'). It cannot read a measure, an aggregate, a window or a parameter. |
Returns
The measure over the rows that the condition keeps, on each row of the result.
Usage notes
- The condition replaces every part of the context, the grouping included. A row’s region or month no longer applies, unless the condition names it.
- The measure’s own definition still applies.
- It cannot be mixed with another modifier in the same
EVAL.
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('online_units', EVAL(orders.sum__quantity, SET_CUSTOM(orders.channel IN ('web', 'email')))) AS "Online Units, All Regions"FROM kater_dataset.orders AS ordersWHERE KATER__IS_NOT_NULL(orders.region)GROUP BY orders.regionORDER BY 1| Region | Units | Online Units, All Regions |
|---|---|---|
| AMER | 2,179 | 4,532 |
| APAC | 2,097 | 4,532 |
| EMEA | 2,421 | 4,532 |
| LATAM | 2,260 | 4,532 |
Online Units is the same on every row: the web and email units of every region. The condition replaced the grouping by region too.
See also
- Change a measure’s context
- Pass through, evaluate or declare
- Other functions in EVAL and its modifiers:
EVAL,CLEAR,REMOVE,SET,CURRENT