Skip to content
Tech Interview Prep
Technical interview guide

Calculated Measures & Aggregations

Writing correct aggregations and calculated measures, where subtle mistakes silently produce wrong numbers.

Minutes to read
3
Practice MCQs
25
Interview Q&A
25
Edition
v5
Editorial status
Reviewed

Scope: Current DAX and Microsoft Power BI, Tableau calculations and LOD expressions, and LookML measure guidance reviewed 2026-09-04.

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

Ratio=∑numerator∑denominator≠average of stored rates\text{Ratio} = \frac{\sum \text{numerator}}{\sum \text{denominator}} \neq \text{average of stored rates} Blended conversion=40+80200+800=12%,not 20%+10%2=15%\text{Blended conversion} = \frac{40 + 80}{200 + 800} = 12\%, \quad \text{not } \frac{20\% + 10\%}{2} = 15\%

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.

Visual axes and slicers Filter context CALCULATE modifies filters Measure evaluated SUMX over a table Row context per row Measure reference: context transition

Write the ratio once and reuse it everywhere:

DAX
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

SituationUseAvoid
Additive total at any grainSUM measureCalculated column frozen at refresh
RatioDIVIDE of two summed measuresAveraging a stored rate column
Count across overlapping groupsDISTINCTCOUNT at the reported grainSumming regional distinct counts
Balance over timePeriod-end value via LASTNONBLANK inside CALCULATESUM across dates
Row key or slicing attributeCalculated column or upstream modelA measure
Per-row value already storedSUM of that columnAn iterator recomputing it

Traps interviewers probe

  1. 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.
  2. 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.
  3. 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]).
  4. 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.
  5. 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.