What Is DAX in Power BI? Beginner's Guide to Measures and Context
By Mirko Peters ·
What is DAX in Power BI? A practical beginner's guide to measures vs calculated columns, row and filter context, CALCULATE, five functions to learn first and the mistakes that produce wrong totals.
DAX, short for Data Analysis Expressions, is the formula language behind every calculation in Power BI. So what is DAX in practice? This guide covers the concepts that matter first, five functions to learn, and the mistakes behind totals nobody trusts.
Key points
- DAX (Data Analysis Expressions) is the formula language of Power BI, Analysis Services and Power Pivot in Excel.
- Ratios belong in measures. Summing or averaging row-level percentages gives wrong totals.
- A DAX function references a whole column or table, never a cell or a cell range like in Excel.
- Measures react to report filters. Calculated columns compute a value for every row and suit slicers, axes and groups.
- Row context is the current row. Filter context is the set of filters that applies to each cell of a visual.
- CALCULATE evaluates an expression in a modified filter context and is the function to learn first.
What is DAX in Power BI?
DAX is used in Analysis Services, Power BI and Power Pivot in Excel, so you learn it once and reuse it in all three. Its functions fall into 14 categories, from aggregation and filter functions to time intelligence and text.
The biggest change for Excel users is the reference model. A DAX function always references a complete column or a table, never a cell or a range. There is no A1. You write Total Sales = SUM(Sales[SalesAmount]) once, and the same formula returns the right number for every region, month and product in a report.
The second change is relationships. Where Excel needs a lookup, a model already relates sales and products. In a calculated column, RELATED fetches the related value.
Where DAX formulas live
| Object | What it does | Typical use |
|---|---|---|
| Measure | Calculates a result that changes with the report's context | Totals, ratios, year-over-year growth |
| Calculated column | Calculates a value for every row of a table | Labels, bands, categories for slicers and axes |
| Calculated table | Builds a table from a formula over other tables | Date table, role-playing copies |
| Row-level security rule | Returns TRUE or FALSE per row for a role | Users see only their region's rows |
Measures vs calculated columns
Measures go in a visual's Values area. Calculated columns become new fields on rows, axes, legends and groups.
A calculated column is computed for every row, so a million rows means a million results, computed at refresh in Import mode. A measure is calculated only for the cells the report shows.
The classic trap is a ratio. As a calculated column, profit margin is correct per row. Show it for a region and Power BI sums or averages those percentages, which is the wrong math. A measure divides the totals for whatever the cell covers:
Margin % = DIVIDE(SUM(Sales[Profit]), SUM(Sales[SalesAmount]))
My rule of thumb: if you need to slice by it, make it a column. If you need to show it as a number, make it a measure. If both would work, take the measure.
Row context and filter context
Context decides which rows a formula sees. Change the context and the same formula returns a different answer.
- Row context is the current row. It exists in a calculated column and inside iterators such as
SUMX, which evaluate an expression for each row of a table. If nothing loops over rows, there is no row context. - Filter context is the set of filters that applies when a value is calculated. Slicers, fields on rows and columns, page filters and cross-filtering from other visuals all add to it.
Both can apply at once. In SUMX(Sales, Sales[Quantity] * Sales[Price]) on a visual filtered to 2025, row context multiplies each row while filter context limits the rows to 2025.
In a table visual with brands down the side, the Total Sales formula never changes. Each cell just carries its own brand filter.
CALCULATE: the function to learn first
CALCULATE evaluates an expression in a modified filter context. For each filter argument, it adds a filter if the column isn't filtered yet, or overwrites the existing filter on that column.
Blue Revenue = CALCULATE(SUM(Sales[SalesAmount]), 'Product'[Color] = "Blue")
Channel Share = DIVIDE(
SUM(Sales[SalesAmount]),
CALCULATE(SUM(Sales[SalesAmount]), REMOVEFILTERS('Sales Order'[Channel]))
)
One limit and one behavior. The limit: a Boolean filter like 'Product'[Color] = "Blue" can reference columns from one table only and can't reference measures. The behavior: in a calculated column or inside an iterator, CALCULATE turns row context into filter context. This is context transition. A Customer column Customer Sales = CALCULATE(SUM(Sales[SalesAmount])) returns each customer's own sales, not the grand total.
Five functions to start with
| Function | What it does | Watch out for |
|---|---|---|
| SUM | Adds up one column in the current filter context | Takes a column, not an expression |
| SUMX | Evaluates an expression per row, then sums | Iterates every row of the table you pass |
| DIVIDE | Divides safely | Returns BLANK, or your alternate result, on a zero or BLANK denominator |
| CALCULATE | Changes the filter context | Boolean filters can't reference measures |
| SAMEPERIODLASTYEAR | Shifts the current dates one year back | Classic time intelligence: needs a date table |
Stack small measures instead of writing one giant formula:
Sales LY = CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))
Sales YoY % = DIVIDE([Total Sales] - [Sales LY], [Sales LY])
Classic time intelligence needs a date table marked as such, with unique dates, no blanks, no gaps, and full years. Calendar-based time intelligence (currently in preview) is the newer option and doesn't require complete dates. For a beginner that means: build a classic date table now, and switch once the feature is generally available.
Common beginner mistakes
- Mixing up row and filter context. Totals that don't add up are usually a context question. Ask which rows the formula sees in that cell.
- Calculated columns for everything. They feel familiar but are computed for every row. Move numeric logic to measures.
- Bidirectional relationships by default. They can hurt query performance and confuse users. If one measure needs it, use
CROSSFILTER(Customer[CustomerCode], Sales[CustomerCode], BOTH)inside that measure's CALCULATE. - Using
/on denominators that can be zero. UseDIVIDEthere and/for constants. - Rewriting before measuring. Open Optimize > Performance Analyzer in Power BI Desktop. It splits each visual's time into DAX query, visual display, other and, for DirectQuery tables, Direct query. You can copy each query.
Microsoft Learn calls including the table name in measure formulas good practice. My recommendation: always prefix columns, never measures, so you can tell them apart at a glance. For teams: keep shared measures in one central semantic model owned by one person or group, so "Total Sales" means the same in every report.
Try it in 30 minutes
Load a sales table and a date table in Power BI Desktop. Create Total Sales, Sales LY and Sales YoY % from above, show them by year and month, and add a region slicer. Predict each number before you click.
Where to go next
Visual calculations handle running totals directly on a visual. Copilot in Power BI can draft DAX you still need to check. Then read What is a semantic model in Fabric?.
Sources
- DAX overview
- Learn DAX basics in Power BI Desktop
- Create measures in Power BI Desktop
- Create calculated columns in Power BI Desktop
- Tutorial: Create calculated columns
- Calculated columns in tabular models
- CALCULATE function
- SUMX function
- DIVIDE function vs divide operator
- SAMEPERIODLASTYEAR function
- Date table guidance
- Time intelligence in Power BI Desktop
- Bi-directional relationship guidance
- Performance Analyzer
FAQ
What is DAX in Power BI in simple terms?
DAX stands for Data Analysis Expressions. It's the formula language you use in Power BI Desktop to create new information from data that is already in your model, such as totals, ratios, prior-year comparisons and labels. The same language is used in Power Pivot in Excel and in Analysis Services.
Should I use a measure or a calculated column?
Use a measure for numbers in the Values area of a visual that should change as users filter the report. Use a calculated column when you need a value per row that you place on rows, axes, legends, slicers or groups. If both would work, prefer the measure, because a calculated column is computed for every row of the table.
What is the difference between row context and filter context?
Row context is the current row, for example while a calculated column or an iterator like SUMX walks through a table. Filter context is the set of filters that applies when a value is calculated, coming from slicers, visual fields, page filters and filters inside the formula. Both can apply at the same time.
Why is CALCULATE so important in DAX?
CALCULATE evaluates an expression in a modified filter context. It can add a filter, overwrite an existing filter on the same column, or remove filters with functions like REMOVEFILTERS. Most comparisons, such as share of total or prior-year sales, are built on it.
Do I need a date table for DAX time intelligence?
Yes. Microsoft Learn states that your model needs at least one date table to work with DAX time intelligence functions. The date column must hold unique dates with no blanks and no gaps, and it must span full years. The newer calendar-based time intelligence (currently in preview) relaxes the no-gaps rule, but beginners should start with a classic date table.