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.
Aggregations
| Name | What it does | Example | Practice |
|---|---|---|---|
| SUM | Adds up a numeric column. | | Your first DAX measures |
| SUM (cost) | A second base measure. Build measures on measures like these instead of repeating the column. | | Your first DAX measures |
| AVERAGE | The mean of a numeric column. | | Your first DAX measures |
| COUNTROWS | Counts the rows of a table after the filters around it apply. | | Count rows, values and blanks |
| DISTINCTCOUNT | Counts the different values in a column, here the customers who bought. | | Count rows, values and blanks |
| DIVIDE | Divides and returns blank, or a value you choose, instead of an error when the denominator is 0. | | DIVIDE: ratios that don't break |
Logic and variables
| Name | What it does | Example | Practice |
|---|---|---|---|
| IF | Returns one value when a condition is true and another when it is false. | | IF and SWITCH |
| SWITCH | Compares a value with a list and returns the result of the first match, or a default at the end. | | IF and SWITCH |
| SELECTEDVALUE | The value of a column when the filters leave exactly one, otherwise the alternate you give. | | SELECTEDVALUE and dynamic labels |
| VAR, RETURN | Stores a result under a name, so the formula reads more easily and the value is calculated once. | | Variables in DAX |
Row by row
| Name | What it does | Example | Practice |
|---|---|---|---|
| SUMX | Calculates an expression for each row of a table and adds up the results. | | Row by row: calculated columns, SUMX and RELATED |
| RELATED | In a calculated column, fetches a value from the related table on the one side of the relationship. | | Row by row: calculated columns, SUMX and RELATED |
Filter context
| Name | What it does | Example | Practice |
|---|---|---|---|
| CALCULATE | Evaluates an expression with filters added or replaced. Most advanced measures start here. | | CALCULATE: change the filter context |
| FILTER | Returns the rows of a table that meet a condition, often as a filter inside CALCULATE. | | FILTER with measures |
| ALL | Removes the filters from a table or column, for example to divide by the grand total. | | ALL and percent of total |
| ALLSELECTED | Removes the filters from inside the visual but keeps the slicers and filters the reader chose. | | Running totals and ALLSELECTED |
| USERELATIONSHIP | Uses an inactive relationship for one calculation, such as sales by ship date instead of order date. | | Role-playing dates: USERELATIONSHIP |
Time intelligence
| Name | What it does | Example | Practice |
|---|---|---|---|
| TOTALYTD | The year-to-date total. It needs a date table marked as one. | | Date tables and time intelligence |
| SAMEPERIODLASTYEAR | The same dates one year earlier, to compare with last year. | | Date tables and time intelligence |
| DATEADD | Shifts the dates in the current context by a number of days, months, quarters or years. | | Month to date and rolling periods |
| DATESINPERIOD | A run of dates that ends on a given date, such as the last three months, for rolling totals. | | Month to date and rolling periods |
Ranking and tables
| Name | What it does | Example | Practice |
|---|---|---|---|
| RANKX | Ranks each item of a table by an expression, here each store by sales. | | RANKX: rank stores and products |
| TOPN | The top N rows of a table by an expression. | | TOPN and top N analysis |
| SUMMARIZE, ADDCOLUMNS | SUMMARIZE groups a table by the columns you choose and ADDCOLUMNS adds calculated columns to the result, here as a calculated table. | | Calculated tables: SUMMARIZE and ADDCOLUMNS |
| CALENDAR | Creates a date table with one row for each day between two dates. | | 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.