DAX Functions in 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()
to evaluate all rows from the dimension tableRANKX(
<table>,
<expression>)
Total Costs RANKX =
RANKX(
ALL(Dim_Sales[Region]),
[Total Costs])
ALL()
to evaluate all rows from the dimension table$$ $$ $$
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 | Meaning |
---|---|
= | Equal to |
== | Strict equal to |
> | Greater than |
< | Smaller than |
>= | Greater than or equal to |
<= | Smaller than or equal to |
<> | Not equal to |
Operator | Meaning |
---|---|
= | Equal to |
== | Strict equal to |
> | Greater than |
< | Smaller than |
>= | Greater than or equal to |
<= | Smaller than or equal to |
<> | Not equal to |
Operator | Meaning | Example |
---|---|---|
& | Concatenates text values | [City]&", "&[State] |
Operator | Meaning |
---|---|
= | Equal to |
== | Strict equal to |
> | Greater than |
< | Smaller than |
>= | Greater than or equal to |
<= | Smaller than or equal to |
<> | Not equal to |
Operator | Meaning | Example |
---|---|---|
& | Concatenates text values | [City]&", "&[State] |
Operator | Meaning | Example |
---|---|---|
&& | AND condition |
([City] = "Bru") && ([Return] = "Yes")) |
|| | OR condition |
([City] = "Bru") || ([Return] = "Yes")) |
IN { } | OR condition for each row |
Product[Color] IN {"Red", "Blue", "Gold"} |
DAX Functions in Power BI