DAX Intermediário no Power BI
Maarten Van den Broeck
Content Developer at DataCamp
DISTINCT(<table> | <table>)
Remove linhas duplicadas de uma tabela ou valores de uma coluna
SELECTCOLUMNS(<table>, <name>, <expression>)
Retorna as colunas selecionadas de outra tabela como uma nova tabela
ADDCOLUMNS(<table>, <name>, <expression>)
Retorna a tabela de entrada com as colunas selecionadas de outra tabela anexadas
SUMMARIZE(<table>,
<groupBy_columnName>,
<name>,
<expression>)
Retorna uma tabela-resumo com os totais por grupo
ADDCOLUMNS(<table>, <name>, <expression>)
Retorna a tabela de entrada com as colunas selecionadas de outra tabela anexadas
ADDCOLUMNS(Fact_table,
"Profit",
Revenue - Costs)
ADDCOLUMNS(<table>, <name>, <expression>)
Retorna a tabela de entrada com as colunas selecionadas de outra tabela anexadas
ADDCOLUMNS(Fact_table,
"Profit",
Revenue - Costs)
| Revenue | Costs | Profit |
|---|---|---|
| 100 | 25 | 75 |
| 150 | 25 | 125 |
ADDCOLUMNS(<table>, <name>, <expression>)
Retorna a tabela de entrada com as colunas selecionadas de outra tabela anexadas
ADDCOLUMNS(Fact_table,
"Profit",
Revenue - Costs)
| Revenue | Costs | Profit |
|---|---|---|
| 100 | 25 | 75 |
| 150 | 25 | 125 |
SELECTCOLUMNS(<table>, <name>, <expression>)
Retorna as colunas selecionadas de outra tabela como uma nova tabela
SELECTCOLUMNS(Fact_table,
"Profit",
Revenue - Costs)
| Profit |
|---|
| 75 |
| 125 |
SUMMARIZE(<table>,
<groupBy_columnName>,
<name>,
<expression>)
Retorna uma tabela-resumo com os totais por grupo
SUMMARIZE(<table>,
<groupBy_columnName>,
<name>,
<expression>)
Retorna uma tabela-resumo com os totais por grupo
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>)
Retorna uma tabela-resumo com os totais por grupo
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() podem gerar resultados inesperados conforme o contexto$$
SUMMARIZE(Amounts,
Amounts[Year],
Amounts[Category]),
"Total Amount",
SUM(Amounts[Amount])
SUMMARIZE() com ADDCOLUMNS() ao criar novas colunasADDCOLUMNS(
SUMMARIZE(Amounts,
Amounts[Year],
Amounts[Category]),
"Total Amount",
SUM(Amounts[Amount])
)
DAX Intermediário no Power BI