DAX

DAX cheat sheet

The functions and patterns that cover most Power BI measures, with the filter-context behaviour that explains them.

Updated September 20, 2026

Aggregations and iterators

Use DIVIDE rather than the / operator so a zero denominator returns blank instead of an error.

Total Sales = SUM ( Sales[Amount] )
Weighted Revenue = SUMX ( Sales, Sales[Qty] * Sales[UnitPrice] )
Avg Order Value = DIVIDE ( [Total Sales], DISTINCTCOUNT ( Sales[OrderID] ) )

CALCULATE and filter modifiers

Sales West = CALCULATE ( [Total Sales], Region[Name] = "West" )
Sales All Regions = CALCULATE ( [Total Sales], REMOVEFILTERS ( Region ) )
Region Share = DIVIDE ( [Total Sales], [Sales All Regions] )

Time intelligence

Time intelligence requires a contiguous date table marked as the date table in the model. Without it, results look plausible and are wrong.

Sales YTD  = TOTALYTD ( [Total Sales], 'Date'[Date] )
Sales LY   = CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
YoY %      = DIVIDE ( [Total Sales] - [Sales LY], [Sales LY] )

Common patterns

NeedPattern
Safe ratioDIVIDE ( numerator, denominator )
Share of totalDIVIDE ( measure, CALCULATE ( measure, REMOVEFILTERS ( table ) ) )
Running totalCALCULATE ( measure, 'Date'[Date] <= MAX ( 'Date'[Date] ) )
Distinct customersDISTINCTCOUNT ( Sales[CustomerID] )
Filtered countCALCULATE ( COUNTROWS ( Sales ), Sales[Status] = "Open" )

Frequently asked questions

Why does my measure show the same total on every row?

The filter context is not reaching the table you are aggregating, usually because of a missing or inactive relationship.

Why is my year-over-year measure blank?

Usually a missing marked date table, or a date table that does not cover the earlier period.

Related reading

Analyze your data with AI

Open the GridMind workspace, bring in a CSV, Excel file or your Power BI model, and let AI build the formulas, charts and dashboards for you.