Stop 15 · Portfolio, PL-300 & InterviewsTopics · 4/7

DAX Interview Questions

Part of the Power BI Roadmap

In short

DAX rounds separate people who copy formulas from people who understand filter context. Expect to write YTD and previous year measures live, and to explain why a total looks wrong.

DAX rounds test whether you understand filter context and CALCULATE, can write YTD, previous year and percent of total measures, and can explain row context, context transition and wrong totals.

The jaadu pours hot coffee through a stack of different coloured paper filters into a row of small glass cups.

Think of it like this

The coffee filter

Every number in a visual is coffee that has passed through a filter: the row's year, the slicer's city, the page filter. CALCULATE lets you swap the filter paper before pouring. Most DAX questions are really asking: what is in the filter right now, and how do you change it?

Watch it happen

Why does the total look wrong?

Pune 1
0
Mumbai 1
1
Nagpur 0
2
Total ?
3

1/5Measure: Cities Above Target = IF ( [Total Sales] > [Target], 1, 0 ). Each city row works: Pune and Mumbai hit target, Nagpur did not.

The big ideas

What you need to know

Filter context

The set of filters from rows, columns, slicers and filters that applies when a measure is evaluated.

Row context

The current row in a calculated column or an iterator like SUMX. It does not filter by itself.

Context transition

CALCULATE turns the current row context into filter context. That's why measures inside iterators work per row.

Time intelligence

TOTALYTD, SAMEPERIODLASTYEAR and DATEADD need a proper Date table marked as a date table.

See it in code

Walk through the code

dax
1Total Sales = SUM ( Sales[Amount] )2 3Sales YTD = TOTALYTD ( [Total Sales], 'Date'[Date], "31/3" )4 5Sales PY =6CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )7 8YoY % = DIVIDE ( [Total Sales] - [Sales PY], [Sales PY] )9 10% of All Regions =11DIVIDE ( [Total Sales], CALCULATE ( [Total Sales], ALL ( Region ) ) )

1/5Always build on a simple base measure.

Five measures that come up again and again. The YTD uses an Indian financial year ending 31 March.

Save yourself the pain

Common mistakes

Oops

Explaining CALCULATE as 'a SUM with a filter'.

Do this instead

Say it evaluates an expression in a modified filter context, and triggers context transition when used in a row context.

Oops

Using the / operator for ratios.

Do this instead

Use DIVIDE. It returns blank, or a value you choose, when the denominator is zero.

Your mission

Write five measures from memory

~30 min

Quick check

What does ALL ( Region ) do inside CALCULATE ( [Total Sales], ALL ( Region ) )?

Go deeper

  1. 1Write CALCULATE, YoY % and % of total measures from memory.
  2. 2Explain the difference between ALL, ALLEXCEPT and ALLSELECTED in your own words.
  3. 3Practise talking through a measure line by line as you write it.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge