DAX has hundreds of functions. Dashboards at work run on about 10.
Count it right, divide safely, change filters, go row by row, compare to last month, bucket values. That's the whole job.
Learn these first.
1-4: count it right, divide and filter
- 01
SUM
The base measure. Everything builds on it.
Total Sales = SUM(Sales[Amount]) - 02
DISTINCTCOUNT
Unique customers, not rows.
Customers = DISTINCTCOUNT(Sales[CustID]) - 03
DIVIDE
Returns blank instead of an error on zero.
AOV = DIVIDE([Total Sales], [Orders]) - 04
CALCULATE
Same measure, changed filter.
UP Sales = CALCULATE([Total Sales], Store[State] = "UP")
5-8: remove filters, row by row
- 05
FILTER
Row-by-row condition inside CALCULATE.
Big Orders = CALCULATE([Orders], FILTER(Sales, Sales[Amount] > 5000)) - 06
ALL
Ignores the slicer for the total. Used for % of total.
% Share = DIVIDE([Total Sales], CALCULATE([Total Sales], ALL(Product))) - 07
SUMX
Multiply per row, then add up.
Revenue = SUMX(Sales, Sales[Qty] * Sales[Price]) - 08
RELATED
Pull a column from the lookup table. Use it in a calculated column on Sales.
Category = RELATED(Product[Category])
9-10: time and buckets
- 09
DATEADD
Last month's sales. Needs a marked Date table.
Sales LM = CALCULATE([Total Sales], DATEADD('Date'[Date], -1, MONTH)) - 10
SWITCH(TRUE())
Cleaner than nested IFs.
Band = SWITCH(TRUE(), [Total Sales] > 100000, "High", [Total Sales] > 50000, "Mid", "Low")
Build these in order. Almost every other measure is CALCULATE([Total Sales], …) with a different filter.