Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training
Data Analytics⏱️ 15 min readπŸ“… Nov 26

DAX Functions Cheat Sheet (2026): 50 Power BI DAX Formulas with Examples

RM
Rohit Malhotraβ€’BI Developer
πŸ“‘ Contents (25 sections)

πŸ“ŒHow to Use This DAX Cheat Sheet

DAX (Data Analysis Expressions) is the formula language of Power BI, Analysis Services and Power Pivot. This cheat sheet groups the DAX functions you will actually use at work and in interviews, each with a short example built on a typical sales model: a Sales fact table, Product, Customer, Store and a marked Date table.

Two ideas explain almost every DAX result:

  • Row context: "the current row". It exists in calculated columns and inside iterators such as SUMX.
  • Filter context: the filters coming from slicers, visual axes, rows and columns, and CALCULATE.
  • New to Power BI? Start with the Power BI tutorial for beginners, then come back here.

    πŸ“Œ1. Aggregation Functions

    Total Sales = SUM ( Sales[SalesAmount] )
    Avg Price = AVERAGE ( Sales[UnitPrice] )
    Min Order Date = MIN ( Sales[OrderDate] )
    Max Order Date = MAX ( Sales[OrderDate] )
    Order Lines = COUNTROWS ( Sales )
    Orders = DISTINCTCOUNT ( Sales[OrderID] )
    Non Blank Email = COUNTA ( Customer[Email] )

    COUNTROWS counts rows of a table and is usually faster and clearer than COUNT on a column. DISTINCTCOUNT is the standard way to count customers or orders.

    πŸ“Œ2. Iterators (the X Functions)

    Iterators walk a table row by row, evaluate an expression, then aggregate.

    Revenue = SUMX ( Sales, Sales[Quantity] * Sales[UnitPrice] )
    Avg Line Value = AVERAGEX ( Sales, Sales[Quantity] * Sales[UnitPrice] )
    Max Order = MAXX ( VALUES ( Sales[OrderID] ), [Total Sales] )
    Product List = CONCATENATEX ( VALUES ( Product[Product] ), Product[Product], ", " )

    Use SUMX when you must multiply or combine columns per row. Use SUM when one column is enough.

    πŸ“Œ3. CALCULATE and Filter Functions

    CALCULATE evaluates an expression in a modified filter context. It is the most important function in DAX.

    Sales South = CALCULATE ( [Total Sales], Store[Region] = "South" )
    Sales All Region = CALCULATE ( [Total Sales], REMOVEFILTERS ( Store[Region] ) )
    Sales All = CALCULATE ( [Total Sales], ALL ( Sales ) )
    Sales Keep Cat = CALCULATE ( [Total Sales], ALLEXCEPT ( Product, Product[Category] ) )
    Big Orders Sales = CALCULATE ( [Total Sales], FILTER ( Sales, Sales[Quantity] > 10 ) )
    Red Only Keep = CALCULATE ( [Total Sales], KEEPFILTERS ( Product[Color] = "Red" ) )
    Selected Region = SELECTEDVALUE ( Store[Region], "All regions" )

  • ALL / REMOVEFILTERS: ignore filters on a table or column. REMOVEFILTERS is the clearer name when used as a CALCULATE modifier.
  • ALLEXCEPT: remove all filters on a table except the listed columns.
  • ALLSELECTED: respect filters from outside the visual (slicers) but ignore the visual's own rows. Used for "% of visible total".
  • FILTER: returns a filtered table. Prefer simple column predicates in CALCULATE; use FILTER for conditions on measures or multiple columns.
  • KEEPFILTERS: intersect with the existing filter instead of replacing it.
  • VALUES / DISTINCT: the distinct values visible in the current filter context.
  • HASONEVALUE / SELECTEDVALUE: check or return a single selected value, useful for dynamic titles.
  • πŸ“Œ4. Time Intelligence Functions

    These need a continuous date table marked as a date table.

    Sales YTD = TOTALYTD ( [Total Sales], 'Date'[Date] )
    Sales QTD = TOTALQTD ( [Total Sales], 'Date'[Date] )
    Sales MTD = TOTALMTD ( [Total Sales], 'Date'[Date] )
    Sales FYTD = TOTALYTD ( [Total Sales], 'Date'[Date], "31/03" )
    Sales LY = CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) )
    Sales LM = CALCULATE ( [Total Sales], DATEADD ( 'Date'[Date], -1, MONTH ) )
    Sales PY Full = CALCULATE ( [Total Sales], PREVIOUSYEAR ( 'Date'[Date] ) )
    Sales Last 30D = CALCULATE ( [Total Sales], DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -30, DAY ) )

    The "31/03" argument in TOTALYTD sets an April to March financial year, which most Indian companies use.

    πŸ“Œ5. Relationship Functions

    Category (col) = RELATED ( Product[Category] )
    Order Count (col)= COUNTROWS ( RELATEDTABLE ( Sales ) )
    Sales by Ship = CALCULATE ( [Total Sales], USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] ) )
    Sales Both Ways = CALCULATE ( [Total Sales], CROSSFILTER ( Sales[CustomerID], Customer[CustomerID], BOTH ) )

  • RELATED goes from the many side to the one side inside a row context.
  • RELATEDTABLE goes the other way and returns the related rows.
  • USERELATIONSHIP activates an inactive relationship, the classic order date versus ship date case.
  • CROSSFILTER changes filter direction for one calculation, safer than a bidirectional relationship in the model.
  • πŸ“Œ6. Logical and Information Functions

    Margin Band = SWITCH ( TRUE (),
    [Margin %] >= 0.4, "High",
    [Margin %] >= 0.2, "Medium",
    "Low" )
    Status = IF ( [Total Sales] > [Target], "On track", "Behind" )
    Safe Ratio = DIVIDE ( [Profit], [Total Sales], 0 )
    Has Sales = NOT ISBLANK ( [Total Sales] )
    Fallback = COALESCE ( [Total Sales], 0 )

    SWITCH(TRUE(), ...) replaces nested IFs and reads far better. DIVIDE handles divide by zero. COALESCE returns the first non blank value.

    πŸ“Œ7. Text Functions

    Full Name = Customer[FirstName] & " " & Customer[LastName]
    Initial = LEFT ( Customer[FirstName], 1 )
    Clean City = UPPER ( TRIM ( Customer[City] ) )
    Month Text = FORMAT ( 'Date'[Date], "MMM YYYY" )
    Code = SUBSTITUTE ( Product[SKU], "-", "" )
    Title = "Sales for " & SELECTEDVALUE ( Store[Region], "all regions" )

    πŸ“Œ8. Ranking and Top N

    Product Rank = RANKX ( ALL ( Product[Product] ), [Total Sales], , DESC, DENSE )
    Top 5 Products Sales =
    CALCULATE ( [Total Sales], TOPN ( 5, ALL ( Product[Product] ), [Total Sales], DESC ) )

    Newer DAX also offers RANK, ROWNUMBER and window functions such as OFFSET, INDEX and WINDOW, which make "previous row" and moving calculations easier on visual level data.

    πŸ“Œ9. Variables

    Variables make DAX faster (each is evaluated once) and much easier to debug.

    Sales YoY % =
    VAR CurrentSales = [Total Sales]
    VAR PriorSales = [Sales LY]
    RETURN
    DIVIDE ( CurrentSales - PriorSales, PriorSales )

    Tip: while debugging, temporarily RETURN one of the variables to check its value.

    πŸ“Œ10. Table Functions You Will Meet

  • SUMMARIZE / SUMMARIZECOLUMNS: group by columns and add aggregates. SUMMARIZECOLUMNS is what Power BI visuals generate.
  • ADDCOLUMNS: add calculated columns to a table expression.
  • CALENDAR / CALENDARAUTO: create a date table.
  • UNION, INTERSECT, EXCEPT: set operations on tables.
  • GENERATESERIES: number series, used by what-if parameters.
  • TREATAS: apply the values of one table as filters on another, used for virtual relationships.
  • πŸ“ŒReady to Copy DAX Patterns

    Percentage of total

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

    Running total

    Running Total =
    CALCULATE ( [Total Sales],
    FILTER ( ALLSELECTED ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) ) )

    Three month moving average

    Sales 3M Avg =
    AVERAGEX (
    DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, MONTH ),
    [Total Sales] )

    For a monthly visual, iterate months rather than days for a true monthly average.

    New customers

    New Customers =
    VAR MinDate = MIN ( 'Date'[Date] )
    RETURN
    COUNTROWS (
    FILTER ( VALUES ( Sales[CustomerID] ),
    CALCULATE ( MIN ( Sales[OrderDate] ), REMOVEFILTERS ( 'Date' ) ) >= MinDate ) )

    Dynamic RLS rule

    [Email] = USERPRINCIPALNAME ()

    Applied on a security table related to the fact table, this shows each signed in user only their rows.

    πŸ“ŒDAX Best Practices

  • 1Write measures, not calculated columns, for anything aggregated.
  • 2Reference measures inside measures, and never repeat logic.
  • 3Use variables and DIVIDE.
  • 4Keep a proper star schema; good modelling makes DAX short. See our star schema guide.
  • 5Avoid FILTER over whole fact tables when a column predicate works.
  • 6Use Performance Analyzer and DAX Studio to find slow measures.
  • 7Format with consistent indentation; tools like DAX Formatter help.
  • πŸ“ŒFrequently Asked Questions

    What is the difference between a measure and a calculated column?

    A calculated column is computed per row at refresh and stored, using memory. A measure is computed at query time in the current filter context. Use measures for KPIs.

    What is context transition?

    When CALCULATE runs inside a row context, it converts the current row into an equivalent filter context. That is why a measure used inside SUMX or a calculated column gives per row results.

    Is DAX the same as Excel formulas?

    The syntax looks similar and many function names match, but DAX works on tables and columns with filter context, not on cells.

    How many DAX functions should I know for interviews?

    Know aggregations, the X iterators, CALCULATE with ALL, REMOVEFILTERS and FILTER, the main time intelligence functions, RELATED and USERELATIONSHIP, RANKX and variables well. Practise with our Power BI interview questions.

    Is DAX tested in PL-300?

    Yes, under modelling the data: measures, CALCULATE, time intelligence and quick measures. See the PL-300 guide.

    πŸ“ŒLearn It Live

    DAX clicks fastest when someone corrects your measures in real time. Prakalpana's Power BI course is taught live online with an optional 1-on-1 track, covering filter context, CALCULATE, time intelligence, performance tuning and real business models. See the full Power BI learning path, then WhatsApp or call +91 9180377502 for a free demo.

    RM

    Written by

    Rohit Malhotra

    BI Developer

    πŸš€ Master Data Analytics

    Live online + 1-on-1 Power BI training Β· Join 5000+ developers

    Not sure what to do? Book career counselling (β‚Ή200 / 30 min)

    Not sure what to learn next?

    A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

    1. 1Discuss your goals
    2. 2Get a personal plan
    3. 3Start learning
    Book for β‚Ή200/ 30 min