Country or region and language

    Choose your country or region and your language.

    Suggested for you

      All countries and regions

        Choose your character

        It shows in the top bar and on your profile. Change it any time.

        The Work Gym / Free resources

        DAX functions cheat sheet

        The 25 DAX functions behind most Power BI reports, grouped by what they do. Each example is a measure, calculated column or table written for one sample sales model, and each row links to a lesson where your measure is checked.

        The examples are written for one sales model with Sales, Product, Store, Customer and Date tables. [Total Sales] and [Total Cost] are the first two measures.

        Each row links to a lesson of the Power BI course, where you practice it and your answer is checked. The first unit is free.

        Aggregations

        NameWhat it doesExamplePractice
        SUMAdds up a numeric column.
        Total Sales = SUM(Sales[Sales Amount])
        Your first DAX measures
        SUM (cost)A second base measure. Build measures on measures like these instead of repeating the column.
        Total Cost = SUM(Sales[Cost])
        Your first DAX measures
        AVERAGEThe mean of a numeric column.
        Avg Quantity = AVERAGE(Sales[Quantity])
        Your first DAX measures
        COUNTROWSCounts the rows of a table after the filters around it apply.
        Orders = COUNTROWS(Sales)
        Count rows, values and blanks
        DISTINCTCOUNTCounts the different values in a column, here the customers who bought.
        Buying Customers = DISTINCTCOUNT(Sales[CustomerKey])
        Count rows, values and blanks
        DIVIDEDivides and returns blank, or a value you choose, instead of an error when the denominator is 0.
        Margin % = DIVIDE([Total Sales] - [Total Cost], [Total Sales])
        DIVIDE: ratios that don't break

        Logic and variables

        NameWhat it doesExamplePractice
        IFReturns one value when a condition is true and another when it is false.
        Target Check = IF([Total Sales] > 100000, "Above target", "Below target")
        IF and SWITCH
        SWITCHCompares a value with a list and returns the result of the first match, or a default at the end.
        Region Label = SWITCH(SELECTEDVALUE(Store[Region]), "West", "Pacific team", "East", "Atlantic team", "Other teams")
        IF and SWITCH
        SELECTEDVALUEThe value of a column when the filters leave exactly one, otherwise the alternate you give.
        Selected Region = SELECTEDVALUE(Store[Region], "All regions")
        SELECTEDVALUE and dynamic labels
        VAR, RETURNStores a result under a name, so the formula reads more easily and the value is calculated once.
        Gross Margin =
        VAR Revenue = [Total Sales]
        VAR Spend = [Total Cost]
        RETURN Revenue - Spend
        Variables in DAX

        Row by row

        NameWhat it doesExamplePractice
        SUMXCalculates an expression for each row of a table and adds up the results.
        Line Revenue = SUMX(Sales, Sales[Quantity] * Sales[Unit Price])
        Row by row: calculated columns, SUMX and RELATED
        RELATEDIn a calculated column, fetches a value from the related table on the one side of the relationship.
        Category = RELATED(Product[Category])
        Row by row: calculated columns, SUMX and RELATED

        Filter context

        NameWhat it doesExamplePractice
        CALCULATEEvaluates an expression with filters added or replaced. Most advanced measures start here.
        Online Sales = CALCULATE([Total Sales], Sales[Channel] = "Online")
        CALCULATE: change the filter context
        FILTERReturns the rows of a table that meet a condition, often as a filter inside CALCULATE.
        Large Orders = CALCULATE(COUNTROWS(Sales), FILTER(Sales, Sales[Sales Amount] > 500))
        FILTER with measures
        ALLRemoves the filters from a table or column, for example to divide by the grand total.
        % of All Stores = DIVIDE([Total Sales], CALCULATE([Total Sales], ALL(Store)))
        ALL and percent of total
        ALLSELECTEDRemoves the filters from inside the visual but keeps the slicers and filters the reader chose.
        % of Selected = DIVIDE([Total Sales], CALCULATE([Total Sales], ALLSELECTED(Store)))
        Running totals and ALLSELECTED
        USERELATIONSHIPUses an inactive relationship for one calculation, such as sales by ship date instead of order date.
        Sales by Ship Date = CALCULATE([Total Sales], USERELATIONSHIP(Sales[ShipDateKey], 'Date'[DateKey]))
        Role-playing dates: USERELATIONSHIP

        Time intelligence

        NameWhat it doesExamplePractice
        TOTALYTDThe year-to-date total. It needs a date table marked as one.
        Sales YTD = TOTALYTD([Total Sales], 'Date'[Date])
        Date tables and time intelligence
        SAMEPERIODLASTYEARThe same dates one year earlier, to compare with last year.
        Sales LY = CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))
        Date tables and time intelligence
        DATEADDShifts the dates in the current context by a number of days, months, quarters or years.
        Sales Last Month = CALCULATE([Total Sales], DATEADD('Date'[Date], -1, MONTH))
        Month to date and rolling periods
        DATESINPERIODA run of dates that ends on a given date, such as the last three months, for rolling totals.
        Sales Last 3 Months = CALCULATE([Total Sales], DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -3, MONTH))
        Month to date and rolling periods

        Ranking and tables

        NameWhat it doesExamplePractice
        RANKXRanks each item of a table by an expression, here each store by sales.
        Store Rank = RANKX(ALL(Store[Store]), [Total Sales])
        RANKX: rank stores and products
        TOPNThe top N rows of a table by an expression.
        Top 3 Products Sales = CALCULATE([Total Sales], TOPN(3, ALL(Product[Product]), [Total Sales]))
        TOPN and top N analysis
        SUMMARIZE, ADDCOLUMNSSUMMARIZE groups a table by the columns you choose and ADDCOLUMNS adds calculated columns to the result, here as a calculated table.
        Sales by Category = ADDCOLUMNS(SUMMARIZE(Sales, Product[Category]), "Sales", [Total Sales])
        Calculated tables: SUMMARIZE and ADDCOLUMNS
        CALENDARCreates a date table with one row for each day between two dates.
        Dates = CALENDAR(DATE(2024, 1, 1), DATE(2025, 12, 31))
        Build a date table with DAX

        Checked against

        Every row was last checked on Nov 20, 2026.

        Questions

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

        A calculated column is computed once per row when the data refreshes and is stored in the table. A measure is computed when a visual asks for it, using the filters on the page, so it changes as the reader slices the report. Most of the examples here are measures.

        Does DAX work in Excel too?

        Yes. Excel's Power Pivot uses the same DAX language, so these functions also work in Excel data models.

        More cheat sheets

        Free resources

        Your Work Gym account

        Save your progress and pick up on another device. Your browser's progress comes with you.

        New accounts get 12 hours of full access: every course, unit, project and exam. The clock starts when you open your first lesson.

        Plan your practice from a job ad or syllabus

        Have a referral code?

        or

        You can keep practicing without an account.

        Change your plan

        Checking the price

        Help and feedback

        Ask a question, tell us what is not working, or share an idea. We reply by email.

        What is it about?

        We use it only to reply to you.