Short answer: DAX table functions return tables. You use them in four places: as filters in CALCULATE (TREATAS, TOPN), as the table an iterator walks (SUMX ( VALUES ( ... ) )), to define calculated tables (DATATABLE, GENERATESERIES), and as the result of DAX queries (SUMMARIZECOLUMNS). This page lists every function in Microsoft's table manipulation group with one example each.
Which functions group?
| Function | Does | Example |
|---|---|---|
| SUMMARIZECOLUMNS | groups by columns of any tables and adds measures | SUMMARIZECOLUMNS ( 'Date'[Year], "Revenue", [Revenue] ) |
| SUMMARIZE | distinct combinations of columns of a table and related ones | SUMMARIZE ( Sales, 'Product'[Category], 'Date'[Year] ) |
| GROUPBY | groups a table, aggregating with CURRENTGROUP | GROUPBY ( T, T[Year], "@Max", MAXX ( CURRENTGROUP ( ), [@Rev] ) ) |
| CURRENTGROUP | the rows of the current group inside GROUPBY | MAXX ( CURRENTGROUP ( ), [@Rev] ) |
| ROLLUP, ROLLUPGROUP, ROLLUPADDISSUBTOTAL, ROLLUPISSUBTOTAL | subtotal rows in SUMMARIZE and SUMMARIZECOLUMNS | SUMMARIZECOLUMNS ( ROLLUPADDISSUBTOTAL ( 'Date'[Year], "IsTotal" ), "Revenue", [Revenue] ) |
| ADDMISSINGITEMS | adds rows with empty values to a SUMMARIZECOLUMNS result | used by Power BI's own queries |
| IGNORE | leaves an expression out of the blank-row test in SUMMARIZECOLUMNS | IGNORE ( [Target] ) |
In depth: SUMMARIZECOLUMNS, SUMMARIZE and ADDCOLUMNS.
Which functions shape and pick rows?
| Function | Does | Example |
|---|---|---|
| ADDCOLUMNS | adds expression columns to a table | ADDCOLUMNS ( VALUES ( Customer[Customer] ), "@Rev", [Revenue] ) |
| SELECTCOLUMNS | keeps or renames columns, or adds expressions | SELECTCOLUMNS ( Customer, "Name", Customer[Customer] ) |
| TOPN | the first N rows by an expression | TOPN ( 10, VALUES ( Customer[Customer] ), [Revenue] ) |
| VALUES | visible distinct values, with the blank row | VALUES ( 'Product'[Category] ) |
| DISTINCT (column) | visible distinct values, without the blank row | DISTINCT ( 'Product'[Category] ) |
| DISTINCT (table) | distinct rows of a table expression | DISTINCT ( UNION ( T1, T2 ) ) |
| FILTERS | values directly filtered on a column | FILTERS ( 'Product'[Color] ) |
| TREATAS | applies a table's values as a filter on other columns | TREATAS ( VALUES ( 'Date'[Year Month] ), Budget[Year Month] ) |
| DETAILROWS | returns the detail rows expression defined for a measure | DETAILROWS ( [Revenue] ) |
In depth: TOPN, VALUES vs DISTINCT, TREATAS.
Which functions combine tables?
| Function | Does | Example |
|---|---|---|
| UNION | appends rows, duplicates kept | UNION ( T1, T2 ) |
| EXCEPT | rows of the first table not in the second | EXCEPT ( CustomersTY, CustomersLY ) |
| INTERSECT | rows of the first table also in the second | INTERSECT ( CustomersTY, CustomersLY ) |
| CROSSJOIN | every combination of rows | CROSSJOIN ( VALUES ( 'Product'[Category] ), VALUES ( Region[Region] ) ) |
| GENERATE | for each row of table1, the rows of table2 evaluated in that row | GENERATE ( VALUES ( 'Date'[Year] ), TOPN ( 3, VALUES ( 'Product'[Product] ), [Revenue] ) ) |
| GENERATEALL | as GENERATE, keeping rows of table1 where table2 is empty | GENERATEALL ( T1, T2 ) |
| NATURALINNERJOIN | joins on common columns with the same lineage | NATURALINNERJOIN ( T1, T2 ) |
| NATURALLEFTOUTERJOIN | as above, keeping all rows of the left table | NATURALLEFTOUTERJOIN ( T1, T2 ) |
| SUBSTITUTEWITHINDEX | a semijoin that replaces common columns with an index | SUBSTITUTEWITHINDEX ( T1, "Index", T2, T2[Key], ASC ) |
The GENERATE example returns the top 3 products of each year. In depth: UNION, EXCEPT, INTERSECT and CROSSJOIN.
Which functions build tables?
| Function | Does | Example |
|---|---|---|
| DATATABLE | a typed table of constants | DATATABLE ( "Name", STRING, { { "A" }, { "B" } } ) |
| ROW | a one-row table with named columns | ROW ( "Revenue", [Revenue] ) |
| GENERATESERIES | a series of numbers in a column named Value | GENERATESERIES ( 0, 100, 10 ) |
| Table constructor | rows from any expressions | { ( "Low", 0 ), ( "High", 1 ) } |
In depth: GENERATESERIES, DATATABLE and ROW. CALENDAR and CALENDARAUTO build date tables (see date and time functions).
What goes wrong?
- A table where a value is expected. A table of one row and one column converts to a value; anything larger errors.
- No sort order. Table functions do not sort; sort in the query or the visual.
- Lineage lost. Columns created with expressions (
SELECTCOLUMNS ( T, "X", T[Col] & "" )) lose their link to the model and do not filter it; useTREATAS. - Large intermediate tables.
CROSSJOINandGENERATEmultiply rows; filter first.
Where can you check this?
- Microsoft Learn: Table manipulation functions (DAX)
- Microsoft Learn: GENERATE function (DAX)
- Microsoft Learn: SELECTCOLUMNS function (DAX)
Where do you start?
Learn VALUES, ADDCOLUMNS, SUMMARIZECOLUMNS, TOPN and TREATAS first; they cover most measures and queries. Window functions work on tables like these, row by row.