Imagine asking someone the exact same question three times and getting three different answers.
A little suspicious, right?
Welcome to DAX.
When I first started learning DAX in Power BI, I thought calculations would be pretty straightforward. Write a formula, Power BI does the maths, and you get an answer.Then I created a simple measure:
Total Quantity = SUM(Shipments[Amount])
Put it on a card? One number.
Put it in a table by product? A different number for every product.
Add a region slicer? The numbers change again.
Same formula. Different answers.So what exactly is going on?
The answer comes down to one of the most important concepts in DAX:
Context.
First things first: what is DAX?
DAX stands for Data Analysis Expressions. It's the formula language used in Power BI to create calculations, from simple totals and averages to comparisons, percentages and time-based analysis.
You can use DAX to create things such as measures, calculated columns and calculated tables.
Functions like SUM, AVERAGE and DISTINCTCOUNT might look familiar.
But knowing the functions is only half the story. Because in DAX, the result of a calculation depends on the context in which it is evaluated.
So, what is context?
Think of context as:
What data can my calculation see right now?
There are two important types to understand: row context and filter context.
Row context: Which row am I on?
Row context means a calculation is being evaluated with a current row in mind.
Imagine a table containing:
Quantity | Unit Price | Revenue
If we create a calculated column for revenue, Power BI works through the table row by row.
For each row, it can take:
Quantity × Unit Price
Row 1 gets its result. Then row 2. Then row 3. And so on.
It's almost like Power BI is asking:
"What are the values on this row?"
That's row context.
Filter context: What am I looking at?
Filter context is different.
Instead of asking which row we're on, we're asking:
"Which part of the data should this calculation currently consider?"
Let's go back to:
Total Quantity = SUM(Shipments[Amount])
Put that measure on a card with no other filters and Power BI can calculate the total quantity across all relevant shipments. Now place Product on the rows of a table. The measure hasn't changed, but each product creates a different filter context.
So instead of calculating:
Total quantity for everything
Power BI is effectively evaluating:
Total quantity for Product A, then Total quantity for Product B, then Total quantity for Product C.
Add a slicer for Region = London?
You've changed the filter context again.
Now Power BI is calculating those product totals using only the data that remains relevant under that selection.
Same measure. Different context. Different answer.
And then there's CALCULATE...
This is where DAX gets even more interesting.
If filter context determines what data a measure can see, CALCULATE allows us to modify that filter context.
Suppose I don't just want total shipment quantity. I specifically want the quantity for Critical Priority shipments.
Conceptually, I'm asking Power BI:
"Calculate my total quantity, but evaluate it for Critical Priority shipments."
That's an important shift, we're not just asking DAX to perform some maths anymore, but we're controlling the conditions under which that maths is evaluated.
And once you understand that, functions such as ALL start making more sense too.
ALL can be used to remove filters from a specified table or column. Why would we want to do that?
Imagine a visual showing each priority level as a percentage of the overall shipment quantity. For each priority level, the visual naturally filters the measure to that category. But to calculate the percentage, we also need the overall total to compare it against, that's where changing or removing filter context becomes incredibly useful.
Why does any of this matter?
Imagine opening a dashboard and seeing:
Total Shipments: 15,000
Great. But...
Is 15,000 good?
How many were critical?
Which region contributed the most?
Are shipments increasing?
How does this compare with last year?
A single total can only tell us so much, DAX allows us to take that number and evaluate it from different perspectives. And that's why understanding context matters.
It's what turns a calculation from:
"How many shipments did we have?"
into:
"How many shipments did we have under these particular conditions, and what does that tell us?"
Same formula. Different story.
My biggest takeaway from learning DAX so far:
The formula matters. But the context around it matters just as much.
Because in data, a number rarely tells the whole story, sometimes, you just need to ask it the right question.
