DAX functions: list with examples

The most important DAX functions for Power BI on one page, sorted by job: aggregate, calculate row by row, change filters, use relationships, logic, text, dates and time intelligence. Every function comes with an example you can try right away in the playground.

In short: DAX functions have English names in every language version of Power BI, arguments are separated by commas and decimals use a point. Columns are written as Table[Column], measures as [Measure].

All examples use a small sales model with the tables Sales, Product, Region and Date and the measure [Total Sales]. You can try each of them in the DAX playground: there you write measures as DEFINE MEASURE Sales[Name] = … in front of a query. We compared the results of all examples with Power BI Desktop.

Jump to: Aggregation, Iterators (row by row), Filter and context, Relationships, Logical and information, Math, Text, Date and time, Time intelligence, Tables and queries

Explained in detail: COUNTIF in DAX, DATEDIFF and the semantic model all measures calculate in.

Cheat sheet as a PDF

The cheat sheet is free as a printable PDF. All you need is a free account, no subscription and no payment details.

Create a free account and download the PDF Already have an account? Log in

Aggregation

FunctionWhat forExampleLesson
SUMSum of a columnTotal Sales = SUM(Sales[Amount])Measures: SUM, COUNTROWS, DISTINCTCOUNT
AVERAGEAverage of a columnAvg Amount = AVERAGE(Sales[Amount])Measures: SUM, COUNTROWS, DISTINCTCOUNT
MIN, MAXSmallest or largest valueLast Order = MAX(Sales[OrderDate])Measures: SUM, COUNTROWS, DISTINCTCOUNT
MEDIANMiddle valueMedian Amount = MEDIAN(Sales[Amount])
COUNTROWSCount the rows of a tableOrders = COUNTROWS(Sales)Measures: SUM, COUNTROWS, DISTINCTCOUNT
COUNT, COUNTA, COUNTBLANKCount values, non-blank values or blank values in a columnNo Ship Date = COUNTBLANK(Sales[ShipDate])
DISTINCTCOUNTCount distinct valuesProducts Sold = DISTINCTCOUNT(Sales[ProductID])Measures: SUM, COUNTROWS, DISTINCTCOUNT
DIVIDEDivide, blank instead of an error when dividing by zeroAvg Order Value = DIVIDE([Total Sales], COUNTROWS(Sales))Dividing with DIVIDE

Iterators (row by row)

FunctionWhat forExampleLesson
SUMXEvaluate an expression per row and add upSales from Quantity = SUMX(Sales, Sales[Quantity] * RELATED(Product[Price]))SUMX and iterators
AVERAGEXAverage of an expression per rowAvg Sales per Region = AVERAGEX(VALUES(Region[Region]), [Total Sales])SUMX and iterators
MINX, MAXXSmallest or largest value of an expression per rowBest Month = MAXX(VALUES('Date'[Month]), [Total Sales])SUMX and iterators
COUNTXCount rows where the expression is not blankRegions with Sales = COUNTX(VALUES(Region[Region]), [Total Sales])
CONCATENATEXJoin texts per row into one textCategories = CONCATENATEX(VALUES(Product[Category]), Product[Category], ", ")
RANKXRank of a value in a listRegion Rank = RANKX(ALL(Region[Region]), [Total Sales])RANKX and TOPN

Filter and context

FunctionWhat forExampleLesson
CALCULATEEvaluate a measure with a changed filterSales North = CALCULATE([Total Sales], Region[Region] = "North")CALCULATE
FILTERKeep the rows of a table where the condition is trueLarge Orders = COUNTROWS(FILTER(Sales, Sales[Amount] > 500))SUMX and iterators
ALLRemove filters from a table or columnShare = DIVIDE([Total Sales], CALCULATE([Total Sales], ALL(Region)))Percent of total with ALL
REMOVEFILTERSLike ALL, but only as a filter in CALCULATESales All Years = CALCULATE([Total Sales], REMOVEFILTERS('Date'))Percent of total with ALL
ALLEXCEPTRemove all filters of a table except on certain columnsCategory Sales = CALCULATE([Total Sales], ALLEXCEPT(Product, Product[Category]))
ALLSELECTEDRemove the row filters, keep the slicersVisible Share = DIVIDE([Total Sales], CALCULATE([Total Sales], ALLSELECTED(Region)))Percent of total with ALL
KEEPFILTERSAdd a filter in CALCULATE instead of replacingHardware Here = CALCULATE([Total Sales], KEEPFILTERS(Product[Category] = "Hardware"))CALCULATE
VALUES, DISTINCTDistinct values of a column in the current filterRegions = COUNTROWS(VALUES(Region[Region]))Filter context
SELECTEDVALUEThe single value of a column, otherwise an alternateTitle = "Sales " & SELECTEDVALUE(Region[Region], "all regions")Filter context
HASONEVALUETrue when exactly one value is in the filterPer Region Only = IF(HASONEVALUE(Region[Region]), [Total Sales])Filter context
ISFILTERED, ISINSCOPEWhether a column is filtered or a row field of the matrixLevel = IF(ISINSCOPE(Product[Product]), "Product", "Category")Hierarchy and drill down
TOPNThe first N rows by a valueTop 3 Products = CALCULATE([Total Sales], TOPN(3, ALL(Product), [Total Sales]))RANKX and TOPN

Relationships

FunctionWhat forExampleLesson
RELATEDFetch a value from the one side of a relationshipCategory = RELATED(Product[Category])Calculated columns
RELATEDTABLERelated rows on the many sideOrders per Product = COUNTROWS(RELATEDTABLE(Sales))LOOKUPVALUE and RELATEDTABLE
USERELATIONSHIPTurn on an inactive relationship in CALCULATESales by Ship Date = CALCULATE([Total Sales], USERELATIONSHIP(Sales[ShipDate], 'Date'[Date]))Cardinality and cross filter direction
LOOKUPVALUELook up a value by a condition, even without a relationshipLaptop Price = LOOKUPVALUE(Product[Price], Product[Product], "Laptop")LOOKUPVALUE and RELATEDTABLE
TREATASApply the values of a table as a filter on another columnSales North South = CALCULATE([Total Sales], TREATAS({"North", "South"}, Region[Region]))

Logical and information

FunctionWhat forExampleLesson
IFOne condition, two resultsTarget Met = IF([Total Sales] > 10000, "yes", "no")IF and SWITCH
SWITCHSeveral cases; with TRUE() several conditionsClass = SWITCH(TRUE(), [Total Sales] > 20000, "A", [Total Sales] > 10000, "B", "C")IF and SWITCH
AND, OR, NOT, &&, ||, INCombine conditionsHardware North East = CALCULATE([Total Sales], Product[Category] = "Hardware", Region[Region] IN {"North", "East"})IF and SWITCH
BLANK, ISBLANKBlank value and the test for itSales or 0 = IF(ISBLANK([Total Sales]), 0, [Total Sales])IF and SWITCH
COALESCEFirst non-blank valueSales with 0 = COALESCE([Total Sales], 0)
IFERRORAlternate value on an errorSafe = IFERROR(1 / COUNTROWS(Sales), 0)

Math

FunctionWhat forExampleLesson
ROUND, ROUNDUP, ROUNDDOWNRound, round up, round downSales Rounded = ROUND([Total Sales], -2)
INT, TRUNC, MODInteger part, remainder of a divisionRemainder = MOD(COUNTROWS(Sales), 7)
ABS, SIGN, POWER, SQRTAbsolute value, sign, power, square rootDistance = ABS([Total Sales] - 20000)

Text

FunctionWhat forExampleLesson
&, CONCATENATEJoin textsLabel = "Sales: " & FORMAT([Total Sales], "#,0")Creating a dashboard
FORMATA number or date as text with a formatMonth = FORMAT(MAX('Date'[Date]), "MMMM yyyy")Creating a dashboard
LEFT, RIGHT, MID, LENParts of a text, lengthCode = LEFT(SELECTEDVALUE(Region[Region], "All"), 1)
UPPER, LOWER, TRIMUpper case, lower case, remove spacesRegion Upper = UPPER(SELECTEDVALUE(Region[Region]))
SEARCH, FIND, SUBSTITUTE, CONTAINSSTRINGFind, replace, contains textWith "top" = CALCULATE([Total Sales], CONTAINSSTRING(Product[Product], "top"))

Date and time

FunctionWhat forExampleLesson
DATE, YEAR, MONTH, DAYBuild or split a dateSales from July = CALCULATE([Total Sales], 'Date'[Date] >= DATE(2026, 7, 1))Date table
WEEKDAY, WEEKNUM, QUARTERDay of week, week number, quarterWeekend = CALCULATE([Total Sales], WEEKDAY('Date'[Date], 2) > 5)
EOMONTH, EDATEEnd of month, date months laterMonth End = EOMONTH(MAX(Sales[OrderDate]), 0)
DATEDIFFDistance between two dates in days, months, yearsAvg Ship Days = AVERAGEX(Sales, DATEDIFF(Sales[OrderDate], Sales[ShipDate], DAY))Calculated columns
CALENDAR, CALENDARAUTOCreate a date tableDate = CALENDAR(DATE(2025, 1, 1), DATE(2026, 12, 31))Date table
TODAY, NOWToday, nowDays Since Last Order = DATEDIFF(MAX(Sales[OrderDate]), TODAY(), DAY)

Time intelligence

FunctionWhat forExampleLesson
TOTALYTD, TOTALMTD, TOTALQTDYear-, month- or quarter-to-date totalSales YTD = TOTALYTD([Total Sales], 'Date'[Date])Time intelligence
DATESYTD, DATESMTD, DATESQTDDates from the start of the year, month or quarterSales YTD = CALCULATE([Total Sales], DATESYTD('Date'[Date]))Time intelligence
SAMEPERIODLASTYEARThe same period last yearSales PY = CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))Time intelligence
DATEADDShift a period by days, months, quarters or yearsSales PM = CALCULATE([Total Sales], DATEADD('Date'[Date], -1, MONTH))Time intelligence
PREVIOUSMONTH, PREVIOUSYEAR, NEXTMONTHWhole previous month, previous year or next monthSales Whole PM = CALCULATE([Total Sales], PREVIOUSMONTH('Date'[Date]))
PARALLELPERIODWhole period shiftedSales Whole PY = CALCULATE([Total Sales], PARALLELPERIOD('Date'[Date], -1, YEAR))
DATESINPERIOD, DATESBETWEENDate range for rolling periodsSales 3 Months = CALCULATE([Total Sales], DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -3, MONTH))

Tables and queries

FunctionWhat forExampleLesson
EVALUATERun a DAX query; the result is a tableEVALUATE TOPN(5, Product, Product[Price], DESC)DAX queries
DEFINE MEASURE, VARMeasures and variables for a queryDEFINE MEASURE Sales[Count] = COUNTROWS(Sales) EVALUATE ROW("Count", [Count])DAX queries
SUMMARIZECOLUMNSGroup with measures, like a matrixEVALUATE SUMMARIZECOLUMNS(Region[Region], "Sales", [Total Sales])DAX queries
ADDCOLUMNS, SELECTCOLUMNSAdd or select columnsEVALUATE ADDCOLUMNS(VALUES(Region[Region]), "Sales", [Total Sales])DAX queries
SUMMARIZEDistinct combinations of columnsEVALUATE SUMMARIZE(Sales, Product[Category], Region[Region])
ROW, DATATABLE, {…}Small table right in the expressionEVALUATE ROW("Orders", COUNTROWS(Sales), "Sales", [Total Sales])DAX queries
UNION, INTERSECT, EXCEPT, CROSSJOINStack tables, intersection, difference, every combinationEVALUATE EXCEPT(VALUES(Region[Region]), {"North"})
GENERATESERIESA series of numbers as a tableEVALUATE GENERATESERIES(1, 5)

Rules that always apply

  • Measure or column: a measure recalculates in the filter of every cell, a calculated column once per row when the data loads. The lesson on measures explains when to use which.
  • Row context: in a calculated column and in iterators such as SUMX there is a current row; Table[Column] returns the value of that row there. In a measure without an iterator every column needs an aggregation such as SUM.
  • CALCULATE replaces filters: a condition on a column replaces the filter on that column, other filters stay. With KEEPFILTERS it is added instead. More in the lesson on CALCULATE.
  • Blank is not zero: BLANK disappears in sums, DIVIDE returns BLANK when the denominator is zero, and in a comparison BLANK counts as 0 or as empty text, so it is smaller than any date.
  • Reserved names: if a table has the name of a DAX word, such as Date, put it in single quotes: 'Date'[Year].
  • TODAY in the exercises: in exercises and the playground TODAY always returns 20 Nov 2026, so that results stay the same. In Power BI it is the real current date.

How to learn DAX

A list does not replace practice. In the Power BI course you write each of these functions yourself, and the server checks your measure on visible and on hidden numbers. That shows whether it is also right in another row, another year or with other data.

Write to us

Choose language

Select your preferred language