Intermediate DAX in Power BI
Maarten Van den Broeck
Content Developer at DataCamp
DISTINCT(<table> | <table>)
Removes duplicate rows from a table or values from a column
SELECTCOLUMNS(<table>, <name>, <expression>)
Returns the selected columns from another table as a new table
ADDCOLUMNS(<table>, <name>, <expression>)
Returns the input table appended with the selected columns from another table
SUMMARIZE(<table>,
<groupBy_columnName>,
<name>,
<expression>)
Returns a summary table for the requested totals over a set of groups
ADDCOLUMNS(<table>, <name>, <expression>)
Returns the input table appended with the selected columns from another table
ADDCOLUMNS(Fact_table,
"Profit",
Revenue - Costs)
ADDCOLUMNS(<table>, <name>, <expression>)
Returns the input table appended with the selected columns from another table
ADDCOLUMNS(Fact_table,
"Profit",
Revenue - Costs)
| Revenue | Costs | Profit |
|---|---|---|
| 100 | 25 | 75 |
| 150 | 25 | 125 |
ADDCOLUMNS(<table>, <name>, <expression>)
Returns the input table appended with the selected columns from another table
ADDCOLUMNS(Fact_table,
"Profit",
Revenue - Costs)
| Revenue | Costs | Profit |
|---|---|---|
| 100 | 25 | 75 |
| 150 | 25 | 125 |
SELECTCOLUMNS(<table>, <name>, <expression>)
Returns the selected columns from another table as a new table
SELECTCOLUMNS(Fact_table,
"Profit",
Revenue - Costs)
| Profit |
|---|
| 75 |
| 125 |
SUMMARIZE(<table>,
<groupBy_columnName>,
<name>,
<expression>)
Returns a summary table for the requested totals over a set of groups
SUMMARIZE(<table>,
<groupBy_columnName>,
<name>,
<expression>)
Returns a summary table for the requested totals over a set of groups
SUMMARIZE(Amounts,Amounts[Year], Amounts[Category],"Total Amount", SUM(Amounts[Amount]))
| Year | Category | Amount |
|---|---|---|
| 2019 | Tickets | 50 |
| 2019 | Postcards | 500 |
| 2020 | Tickets | 200 |
| 2020 | Tickets | 400 |
SUMMARIZE(<table>,
<groupBy_columnName>,
<name>,
<expression>)
Returns a summary table for the requested totals over a set of groups
SUMMARIZE(Amounts,Amounts[Year], Amounts[Category],"Total Amount", SUM(Amounts[Amount]))
| Year | Category | Amount |
|---|---|---|
| 2019 | Tickets | 50 |
| 2019 | Postcards | 500 |
| 2020 | Tickets | 200 |
| 2020 | Tickets | 400 |
$$
| Year | Category | Total Amount |
|---|---|---|
| 2019 | Tickets | 50 |
| 2019 | Postcards | 500 |
| 2020 | Tickets | 600 |
SUMMARIZE() can give unexpected results based on context$$
SUMMARIZE(Amounts,
Amounts[Year],
Amounts[Category]),
"Total Amount",
SUM(Amounts[Amount])
ADDCOLUMNS() around SUMMARIZE() when creating new columnsADDCOLUMNS(
SUMMARIZE(Amounts,
Amounts[Year],
Amounts[Category]),
"Total Amount",
SUM(Amounts[Amount])
)
Intermediate DAX in Power BI