Skip to main content
On this page

Kater SQL Functions Field declarations

NOT_ADDITIVE_ACROSS

Names the dimensions that a measure cannot be added up across, such as an amount across currencies.

Family: Field declarations

Write it as the last argument of MEASURE.

Syntax

MEASURE('name', expression, NOT_ADDITIVE_ACROSS(dimension, ...))

Arguments

ArgumentDescription
dimensionA dimension of the same SELECT, by its field name, such as currency. Give one or more.

Returns

Nothing of its own. It is part of the measure that holds it.

Usage notes

  • Each result row must have one value of each dimension it names. Group by the dimension, filter it to one value, or SET it.
  • A query that adds the measure up across the dimension does not compile. The sample shop’s Revenue gives “Revenue cannot be added up across Currency. Group by Currency or filter it to one value.”
  • A measure that passes this one through, or a measure built on it, keeps the rule.
  • An Excel formula column cannot add up such a measure across the dimension either. [#total spend] is refused, and SUMIF([currency], [@currency], [spend]) adds it up for each currency.

Example

This Sandbox query reads the sample shop’s orders. The table shows the rows that Kater gave.

EMEA sells in euros and in dollars. Grouped by currency, each row has one currency, so the amount adds up.

SELECT
orders.currency AS "Currency",
MEASURE('discounted_amount', KATER__SUM(orders.amount * (1 - orders.discount)), NOT_ADDITIVE_ACROSS(currency)) AS "Discounted Amount"
FROM kater_dataset.orders AS orders
WHERE
KATER__IS_EQUAL_TO(orders.region, 'EMEA')
GROUP BY
orders.currency
ORDER BY
1
CurrencyDiscounted Amount
EUR79,831.36
USD34,322.59

See also