DAX intermedio in Power BI
Maarten Van den Broeck
Content Developer at DataCamp
DISTINCT(<table> | <table>)
Rimuove duplicati da una tabella o valori da una colonna
SELECTCOLUMNS(<table>, <name>, <expression>)
Restituisce le colonne selezionate da un'altra tabella come nuova tabella
ADDCOLUMNS(<table>, <name>, <expression>)
Restituisce la tabella di input con colonne aggiunte selezionate da un'altra tabella
SUMMARIZE(<table>,
<groupBy_columnName>,
<name>,
<expression>)
Restituisce una tabella riepilogativa con i totali richiesti per gruppi
ADDCOLUMNS(<table>, <name>, <expression>)
Restituisce la tabella di input con colonne aggiunte selezionate da un'altra tabella
ADDCOLUMNS(Fact_table,
"Profit",
Revenue - Costs)
ADDCOLUMNS(<table>, <name>, <expression>)
Restituisce la tabella di input con colonne aggiunte selezionate da un'altra tabella
ADDCOLUMNS(Fact_table,
"Profit",
Revenue - Costs)
| Revenue | Costs | Profit |
|---|---|---|
| 100 | 25 | 75 |
| 150 | 25 | 125 |
ADDCOLUMNS(<table>, <name>, <expression>)
Restituisce la tabella di input con colonne aggiunte selezionate da un'altra tabella
ADDCOLUMNS(Fact_table,
"Profit",
Revenue - Costs)
| Revenue | Costs | Profit |
|---|---|---|
| 100 | 25 | 75 |
| 150 | 25 | 125 |
SELECTCOLUMNS(<table>, <name>, <expression>)
Restituisce le colonne selezionate da un'altra tabella come nuova tabella
SELECTCOLUMNS(Fact_table,
"Profit",
Revenue - Costs)
| Profit |
|---|
| 75 |
| 125 |
SUMMARIZE(<table>,
<groupBy_columnName>,
<name>,
<expression>)
Restituisce una tabella riepilogativa con i totali richiesti per gruppi
SUMMARIZE(<table>,
<groupBy_columnName>,
<name>,
<expression>)
Restituisce una tabella riepilogativa con i totali richiesti per gruppi
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>)
Restituisce una tabella riepilogativa con i totali richiesti per gruppi
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() possono dare risultati inattesi in base al contesto$$
SUMMARIZE(Amounts,
Amounts[Year],
Amounts[Category]),
"Total Amount",
SUM(Amounts[Amount])
ADDCOLUMNS() attorno a SUMMARIZE() quando crei nuove colonneADDCOLUMNS(
SUMMARIZE(Amounts,
Amounts[Year],
Amounts[Category]),
"Total Amount",
SUM(Amounts[Amount])
)
DAX intermedio in Power BI