All articles

DAX · Beginners

DAX tutorial for beginners: the formulas you'll use every day

A practical DAX tutorial for Power BI: measures, SUM, DIVIDE, IF, CALCULATE, iterators and time intelligence, with examples you can type and check.

3 November 2026·3 min read·Sources listed at the end

fx Total Sales = SUM(financials[Sales])118.73MTotal SalesSUMDIVIDEIFCALCULATESUMXTOTALYTDThe visual decides the filters. The measure decides the math.

DAX (Data Analysis Expressions) is the formula language of Power BI. It looks like Excel formulas, and that’s exactly what trips people up: it works on whole tables and columns, not on cells. This tutorial covers the handful of patterns behind most real reports, in the order you’ll need them.

Every example uses the free practice data: a table called financials with one row per sale.

1. Measures, not cells

A measure is a named calculation that Power BI runs for every cell of a visual, under that cell’s filters:

Total Sales = SUM(financials[Sales])

Put it in a table by Country and each row shows that country’s sales; the total row shows all of them, 118,726,350.26. You wrote one formula; Power BI ran it six times. That’s the core idea of DAX: the visual decides the filters, the measure decides the math.

2. Basic aggregations

Function Returns Example
SUM Total of a column SUM(financials[Profit])
AVERAGE Mean AVERAGE(financials[Sale Price])
MIN / MAX Smallest / largest MAX(financials[Sales]) → 1,159,200
COUNTROWS Number of rows COUNTROWS(financials) → 700
DISTINCTCOUNT Number of different values DISTINCTCOUNT(financials[Product]) → 6

3. Ratios with DIVIDE

Profit Margin = DIVIDE([Total Profit], [Total Sales])

Always use DIVIDE instead of /: it returns blank, not an error, when the bottom number is zero. Notice the measure refers to other measures in square brackets. Build small measures and combine them.

4. Logic with IF and SWITCH

Margin Status = IF([Profit Margin] >= 0.15, "On target", "Below target")

For more than two outcomes, SWITCH(TRUE(), …) reads better than nested IFs:

Size = SWITCH(TRUE(), [Total Sales] > 24000000, "Large", [Total Sales] > 21000000, "Medium", "Small")

5. CALCULATE: change the filters

CALCULATE evaluates an expression after changing the filters. It’s the most important function in DAX:

Canada Sales = CALCULATE([Total Sales], financials[Country] = "Canada")

That’s 24,887,654.88, on every row of a table, because the filter on Country is replaced. Share of total uses the same idea, removing the filter instead:

% of Total = DIVIDE([Total Sales], CALCULATE([Total Sales], REMOVEFILTERS(financials)))

More in CALCULATE in plain English.

6. Iterators: row by row

SUM adds a column. When you need a calculation per row first, use an iterator such as SUMX:

Gross Revenue = SUMX(financials, financials[Units Sold] * financials[Sale Price])

SUMX goes through the table one row at a time, multiplies, then adds the results. AVERAGEX, MAXX and COUNTX work the same way. The difference between “per row” and “per filter” is explained in filter context and row context.

7. Time intelligence

With a proper date table connected to your data, comparisons over time take one line:

Sales YTD = TOTALYTD([Total Sales], Dates[Date])
Sales LY = CALCULATE([Total Sales], SAMEPERIODLASTYEAR(Dates[Date]))

Without a date table, these return wrong or blank results. See date tables.

Common beginner mistakes

  • A calculated column where a measure belongs. Totals and ratios are measures. See measures vs calculated columns.
  • Hard-coding numbers. [Total Sales] / 6 breaks when a filter removes a product; DISTINCTCOUNT doesn’t.
  • Trusting the total row. Totals re-run the measure; they don’t add the rows. See why your total is wrong.

Practise it

Every function above has its own page in the DAX function reference, with the syntax, each argument and worked examples.

Reading DAX isn’t the same as writing it. The DAX lessons have you type each formula in a practice copy of Power BI, and check the result against the real answer.

Sources

Practice it

Your first measure: SUM

Write DAX measures and use them in visuals.

Open the lesson

Read next