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
| Argument | Description |
|---|---|
measure | The measure to work out. |
dimension | A 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
EVALwithREMOVE. KATER__IGNORE_GROUPING_BYwritesEVALwithREMOVE, notCALCULATE_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 ordersWHERE KATER__IS_EQUAL_TO(orders.region, 'AMER')GROUP BY orders.region, orders.channelORDER BY 2| Region | Channel | Units | Units on All Channels |
|---|---|---|---|
| AMER | 546 | 2,179 | |
| AMER | paid | 604 | 2,179 |
| AMER | store | 534 | 2,179 |
| AMER | web | 495 | 2,179 |
See also
- Change a measure’s context
- Other functions in Calculation context:
TOTAL,SHARE_OF_TOTAL,VALUE_FOR,CALCULATE_BY,CALCULATE_PER,RATIO,RUNNING_TOTAL,MOVING_AVERAGE,CUMULATIVE_SHARE,BY,ACROSS,IGNORE_FILTERS