Skip to main content
On this page

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

ArgumentDescription
measureThe 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 changesOptional. 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 SET must be a constant. To compare each row with the row before, use EVAL with CURRENT.
  • 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 orders
WHERE
KATER__IS_NOT_NULL(orders.region)
GROUP BY
orders.region
ORDER BY
1
RegionUnitsWeb Units
AMER2,179495
APAC2,097520
EMEA2,421577
LATAM2,260504

See also