Overview
Curated: · Written: · Reviewed:
Calculated Measures & Aggregations
In one line
A calculated measure is a business definition evaluated at query time under the filter context the visual supplies. Reach for one when the value is an aggregation or ratio that must hold at every grain and in every total. Do not use one for anything that must be frozen at refresh.
Key definitions
- Filter context: the filters in force when a measure is evaluated: visual axes, slicers, page filters, cross-filtering, and CALCULATE arguments.
- Row context: the current row in a calculated column or in an iterator such as SUMX. It filters nothing by itself.
- Context transition: referencing a measure inside a row context wraps it in an implicit CALCULATE, which turns the current row into a filter that propagates along relationships.
- Additive, semi-additive, non-additive: a measure sums across all dimensions, sums across every dimension except time, or cannot be summed at all.
- BLANK: no value. It is not zero, and the two behave differently in ratios and comparisons.
Formulas and complexity
SUM(Sales[Amount]) scans one column in the storage engine. SUMX(Sales, ...) evaluates its expression once per row of the table it iterates, so its cost grows with table size.
How it works
A visual or slicer supplies a filter context. CALCULATE replaces any existing filter on the same column, KEEPFILTERS intersects with it, and REMOVEFILTERS clears it. An iterator creates a row context for each row, and a measure referenced inside that row context undergoes context transition.
Write the ratio once and reuse it everywhere:
Conversion % = DIVIDE ( [Orders], [Sessions] )At a Region grain, one region has Orders 40 and Sessions 200, and another has Orders 80 and Sessions 800. The per-region cells return 20% and 10%. The grand total returns 12%, because DIVIDE runs over the summed Orders (120) and summed Sessions (1,000). A region with no sessions returns BLANK, and the visual suppresses the cell.
When to use and when not to
| Situation | Use | Avoid |
|---|---|---|
| Additive total at any grain | SUM measure | Calculated column frozen at refresh |
| Ratio | DIVIDE of two summed measures | Averaging a stored rate column |
| Count across overlapping groups | DISTINCTCOUNT at the reported grain | Summing regional distinct counts |
| Balance over time | Period-end value via LASTNONBLANK inside CALCULATE | SUM across dates |
| Row key or slicing attribute | Calculated column or upstream model | A measure |
| Per-row value already stored | SUM of that column | An iterator recomputing it |
Traps interviewers probe
- Averaging percentages. Segment A has 1,000 sessions at 5% (50 conversions), and segment B has 100 sessions at 40% (40 conversions). Their average is 22.5%. The correct figure is 90 / 1,100 = 8.2%. Fix: divide the summed conversions by the summed sessions.
- Assuming row context filters the table. A row over Customers does not restrict Sales to that customer. Fix: reference a measure, which triggers context transition, or write an explicit CALCULATE.
- Clearing too much in a denominator. REMOVEFILTERS on the whole table also strips date and security filters, which leaks a global number. Fix: remove only the dimension being shared, for example REMOVEFILTERS(Sales[Region]).
- Filling blanks with zero. A third DIVIDE argument of 0 asserts that no revenue means 0% margin, which is usually false. Fix: keep the BLANK default so the visual suppresses the cell and downstream ratios stay blank.
- Summing semi-additive or distinct values. Summing account balances across months, or summing regional distinct customer counts, gives a number with no meaning. Fix: use period-end logic for balances and a distinct count over the combined population for customers.
Interview tips
Open by naming the grain of the fact table, the context the expression runs in, and the additivity of the measure. Then state what it returns when there is no data.
Expect these follow-ups:
- The total of a ratio.
- A measure that should ignore one slicer but keep another.
- Month-end balance versus monthly sum.
- Order date versus ship date through an inactive relationship, handled with USERELATIONSHIP.
- A total that leaks a protected value under row-level security.
- Rounding money by computing shares in integer cents and assigning the remainder explicitly, so the parts sum to the whole.
30-second outline: define the measure and its grain in one sentence. Name the numerator and denominator as summed measures. State the context it runs in and which filters must survive. State its additivity, then what it returns when there is no data.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.