DAX cheat sheet¶
Use this as a reminder after completing the lessons, not as a substitute for model and context reasoning.
| Need | Pattern | Check |
|---|---|---|
| Additive measure | SUM(Sales[SalesAmount]) |
Column grain and numeric type |
| Row arithmetic | SUMX(Sales, Sales[Quantity] * Sales[UnitPrice]) |
Eligible rowset and row context |
| Profit | [Revenue] - [Cost] |
Both evaluated in the same intended context |
| Margin | DIVIDE([Gross Profit], [Revenue]) |
Undefined denominator stays BLANK unless specified |
| Replace a column filter | CALCULATE([Revenue], DimRegion[Region] = "North") |
Existing filter on that column is replaced |
| Intersect a filter | KEEPFILTERS(DimRegion[Region] = "North") |
South intersect North has no rows |
| Remove product filters | REMOVEFILTERS(DimProduct) |
Region/Date remain |
| Selected visual total | ALLSELECTED(DimProduct) |
Outer selections and iterator context |
| Classic YTD | TOTALYTD([Revenue], DimDate[Date]) |
Marked complete date table and active date path |
| Classic prior year | SAMEPERIODLASTYEAR(DimDate[Date]) |
Actual calendar and missing periods |
| Alternate date | USERELATIONSHIP(DimDate[Date], Sales[ShipDate]) |
Existing relationship; security limitations |
| Query a scalar | EVALUATE ROW("Value", [Revenue]) |
Measure must be saved or defined in the query |
| Top products | TOPN(N, table, expression, DESC) |
Ties and explicit ORDER BY |
| Test blanks | ISBLANK(expression) |
Do not assume SQL NULL coercion |
Three rules worth memorizing¶
- A grand total re-evaluates the measure in total context.
- A scalar variable is an evaluated value, not a delayed measure.
- A filter or hidden field is not row-level authorization.
Fixture checkpoints¶
Revenue 9500; Cost 6420; Profit 3080; Units 62; Transactions 12. North 4100; South 5400. Laptop 8000; Mouse 800; Keyboard 700. February 2026 Revenue 3700; YTD 6100; PY 2300; Ship Revenue 3300.
See the catalog for canonical source and downloads, troubleshooting for failure diagnosis, and official references for function details.