Fungsi DAX di Power BI
Maarten Van den Broeck
Content Developer at DataCamp
SUMX(<table>, <expression>)
AVERAGEX(<table>, <expression>)
Cost = Fact_Orders[Sales] - Fact_Orders[Profit]
Total Costs = SUM(Fact_Orders[Cost])
| Sales | Profit | Cost |
|---|---|---|
| $77.88 | $3.89 | $73.99 |
| $22.72 | $10.22 | $12.50 |
| ... | ... | ... |
| Total Costs |
|---|
| $2,569 |
Cost = Fact_Orders[Sales] - Fact_Orders[Profit]
Total Costs = SUM(Fact_Orders[Cost])
| Sales | Profit | Cost |
|---|---|---|
| $77.88 | $3.89 | $73.99 |
| $22.72 | $10.22 | $12.50 |
| ... | ... | ... |
| Total Costs |
|---|
| $2,569 |
Total Costs SUMX =
SUMX(Fact_Orders,
Fact_Orders[Sales] - Fact_Orders[Profit])
| Total Costs SUMX |
|---|
| $2,569 |
SUMX(
FILTER(
<table>,
<filter>),
<expression>)
Total Costs East SUMX =
SUMX(
FILTER(
Fact_Orders,
Fact_Orders[Region] = "East"),
Fact_Orders[Sales] - Fact_Orders[Profit])
SUMX(
FILTER(
<table>,
<filter>),
<expression>)
Total Costs East SUMX =
SUMX(
FILTER(
Fact_Orders,
Fact_Orders[Region] = "East"),
Fact_Orders[Sales] - Fact_Orders[Profit])
$$ $$ $$ $$ $$ $$
| Region | Total Costs | Total Costs East SUMX |
|---|---|---|
| Central | $501,239.89 | |
| East | $678,781.24 | $678,781.24 |
| South | $391,721.91 | |
| West | $725,457.82 | |
| TOTAL | $2,297,200.86 | $678,781.24 |
RANKX(
<table>,
<expression>)
Total Costs RANKX =
RANKX(
ALL(Dim_Sales[Region]),
[Total Costs])
ALL() untuk mengevaluasi semua baris dari tabel dimensiRANKX(
<table>,
<expression>)
Total Costs RANKX =
RANKX(
ALL(Dim_Sales[Region]),
[Total Costs])
ALL() untuk mengevaluasi semua baris dari tabel dimensi$$ $$ $$
| Region | Total Costs | Total Costs RANKX |
|---|---|---|
| Central | $725,457.82 | 1 |
| East | $678,781.24 | 2 |
| South | $501,239.89 | 3 |
| West | $391,721.91 | 4 |
| Operator | Arti |
|---|---|
| = | Sama dengan |
| == | Sama persis |
| > | Lebih besar dari |
| < | Lebih kecil dari |
| >= | Lebih besar atau sama |
| <= | Lebih kecil atau sama |
| <> | Tidak sama dengan |
| Operator | Arti |
|---|---|
| = | Sama dengan |
| == | Sama persis |
| > | Lebih besar dari |
| < | Lebih kecil dari |
| >= | Lebih besar atau sama |
| <= | Lebih kecil atau sama |
| <> | Tidak sama dengan |
| Operator | Arti | Contoh |
|---|---|---|
| & | Menggabungkan teks | [City]&", "&[State] |
| Operator | Arti |
|---|---|
| = | Sama dengan |
| == | Sama persis |
| > | Lebih besar dari |
| < | Lebih kecil dari |
| >= | Lebih besar atau sama |
| <= | Lebih kecil atau sama |
| <> | Tidak sama dengan |
| Operator | Arti | Contoh |
|---|---|---|
| & | Menggabungkan teks | [City]&", "&[State] |
| Operator | Arti | Contoh |
|---|---|---|
| && | Kondisi AND |
([City] = "Bru") && ([Return] = "Yes")) |
| || | Kondisi OR |
([City] = "Bru") || ([Return] = "Yes")) |
| IN { } | Kondisi OR per baris |
Product[Color] IN {"Red", "Blue", "Gold"} |
Fungsi DAX di Power BI