DAX function
VAR / RETURN — DAX function reference
Store a value for reuse.
Syntax
dax
VAR <name> = <expression> [VAR <name2> = <expression2>] RETURN <expression using the names>
Examples
dax
VAR Total = SUM(Sales[Amount]) RETURN Total * 1.1
→ A value
dax
VAR CurrentSales = SUM(Sales[Amount])
VAR PriorSales = CALCULATE(SUM(Sales[Amount]), DATEADD('Date'[Date], -1, YEAR))
VAR Growth = DIVIDE(CurrentSales - PriorSales, PriorSales)
RETURN
IF(ISBLANK(PriorSales), BLANK(), Growth)→ Year-over-year growth %, computed once and reused
dax
VAR SelectedRegion = SELECTEDVALUE(Sales[Region]) RETURN "Showing: " & COALESCE(SelectedRegion, "all regions")
→ A dynamic title string
Common mistakes & gotchas
- Variables are evaluated once at their definition point. They improve readability and performance, and they capture the value before later context changes.
- Each VAR is evaluated lazily but only once, in the filter/row context at its definition point — a nested CALCULATE later in the expression does not retroactively change an already-defined variable’s value.
- Variables can hold entire tables, not just scalars — VAR RankedProducts = TOPN(10, Product, [Total Sales]) is valid and lets you reuse a filtered/sorted table without recomputing it.
Related DAX functions
From Iterators & variables