Cheat sheet, 5 min read, updated 30 September 2026

DAX cheat sheet for Power BI

The DAX patterns behind almost every Power BI report, on one printable page.

Power BIDAX
All cheat sheets and guides
All guides and cheat sheets

Base measures

DAX
Total Sales = SUM ( Sales[Amount] )
Orders = DISTINCTCOUNT ( Sales[OrderID] )
AOV = DIVIDE ( [Total Sales], [Orders] )
Customers = DISTINCTCOUNT ( Sales[CustomerID] )

CALCULATE

DAX
Coffee Sales =
CALCULATE ( [Total Sales], 'Product'[Category] = "Coffee" )

Coffee (keep slicer) =
CALCULATE ( [Total Sales],
    KEEPFILTERS ( 'Product'[Category] = "Coffee" ) )

Percentage of total

DAX
% of Total =
DIVIDE ( [Total Sales],
    CALCULATE ( [Total Sales], REMOVEFILTERS ( 'Product' ) ) )

% of Visible Total =
DIVIDE ( [Total Sales],
    CALCULATE ( [Total Sales], ALLSELECTED ( 'Product' ) ) )

Time intelligence

DAX
Sales LY = CALCULATE ( [Total Sales],
    SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
Sales YTD = TOTALYTD ( [Total Sales], 'Date'[Date] )
Sales MTD = TOTALMTD ( [Total Sales], 'Date'[Date] )
Sales PM = CALCULATE ( [Total Sales],
    DATEADD ( 'Date'[Date], -1, MONTH ) )

Year over year

DAX
Sales YoY % =
VAR Curr = [Total Sales]
VAR Prev = [Sales LY]
RETURN DIVIDE ( Curr - Prev, Prev )

Rolling periods

DAX
Sales Rolling 3M =
CALCULATE ( [Total Sales],
    DATESINPERIOD ( 'Date'[Date],
        MAX ( 'Date'[Date] ), -3, MONTH ) )

Iterators

DAX
Revenue = SUMX ( Sales, Sales[Qty] * Sales[Price] )
Avg Daily Sales =
AVERAGEX ( VALUES ( 'Date'[Date] ), [Total Sales] )
Max Order = MAXX ( VALUES ( Sales[OrderID] ), [Total Sales] )

Filtering tables

DAX
Big Customers =
COUNTROWS (
    FILTER ( VALUES ( Customer[CustomerID] ),
        [Total Sales] > 1000 ) )

Ranking

DAX
Product Rank =
RANKX ( ALL ( 'Product'[ProductName] ),
    [Total Sales], , DESC, DENSE )

Selected values

DAX
Selected Region =
SELECTEDVALUE ( Store[Region], "All regions" )

Title = "Sales for " & [Selected Region]

Logic and blanks

DAX
IF ( ISBLANK ( [Sales LY] ), BLANK (), [Sales YoY %] )
SWITCH ( TRUE (),
    [AOV] >= 50, "High",
    [AOV] >= 25, "Medium",
    "Low" )
COALESCE ( [Total Sales], 0 )

Good habits

Use a star schema with a marked date table. Build base measures first, then reuse them. Use DIVIDE instead of the slash operator. Name measures clearly and group them in display folders.

Written by Alessandro Ecclesie Agazzi, freelance analytics engineer in London. Updated 30 September 2026.