Kater SQL Functions Calculation context
VALUE_FOR
Works a measure out for one value of a dimension, such as the web channel, on each row.
Family: Calculation context
The rows shown do not change.
Syntax
VALUE_FOR(measure, SET(dimension = value) [, more context changes])Arguments
| Argument | Description |
|---|---|
measure | The measure to work out. |
SET(dimension = value) | The dimension and its one value, such as SET(orders.channel = 'web'). It replaces the dimension’s grouping and filter. |
more context changes | Optional. More SETs, IGNORE_FILTERS, or one BY or ACROSS. |
Returns
The measure for that value, on each row of the result.
Usage notes
- The value in
SETmust be a constant. To compare each row with the row before, useEVALwithCURRENT. - The other dimensions of the row stay. In the example, each region’s row shows that region’s web units.
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', VALUE_FOR(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
- Other functions in Calculation context:
TOTAL,SHARE_OF_TOTAL,CALCULATE_ACROSS,CALCULATE_BY,CALCULATE_PER,RATIO,RUNNING_TOTAL,MOVING_AVERAGE,CUMULATIVE_SHARE,BY,ACROSS,IGNORE_FILTERS