Skip to main content
On this page

Kater SQL Functions Calculation context

CALCULATE_ACROSS

Removes the dimensions you name from a measure's grouping, and keeps the query's filters.

Family: Calculation context

For a measure, TOTAL with ACROSS gives the same value.

Syntax

CALCULATE_ACROSS(measure, dimension, ...)

Arguments

ArgumentDescription
measureThe measure to work out.
dimensionA dimension that the query groups by, such as orders.channel. Give one or more.

Returns

The measure without those dimensions, on each row of the result.

Usage notes

  • The query’s filters stay, those on the removed dimensions included. To drop them as well, use EVAL with REMOVE.
  • KATER__IGNORE_GROUPING_BY writes EVAL with REMOVE, not CALCULATE_ACROSS, so it drops those filters.

Example

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

SELECT
orders.region AS "Region",
orders.channel AS "Channel",
EVAL(orders.sum__quantity) AS "Units",
MEASURE('region_units', CALCULATE_ACROSS(orders.sum__quantity, orders.channel)) AS "Units on All Channels"
FROM kater_dataset.orders AS orders
WHERE
KATER__IS_EQUAL_TO(orders.region, 'AMER')
GROUP BY
orders.region,
orders.channel
ORDER BY
2
RegionChannelUnitsUnits on All Channels
AMERemail5462,179
AMERpaid6042,179
AMERstore5342,179
AMERweb4952,179

See also