Month-over-month change with VAR and RETURN
Calculate the percent change from last month in one readable measure, using variables to name each piece.
You will learn to
- Store intermediate results with VAR
- Return a result built from variables
- Calculate a month-over-month percent change
How it works
A **variable** gives a name to part of a calculation. Write `VAR Name = expression` for each piece, then `RETURN` the final result. Each variable is calculated once, in the current row’s filter context.
Variables make longer measures easy to read and to check. Instead of repeating the previous-month CALCULATE twice, you name it once and use the name.
Month-over-month change follows the same growth formula as year over year: **(this month − last month) ÷ last month**. Only the comparison period changes.
Practice it hands-on with a real data model and a live report that updates as you type.
YoY % =
VAR ThisYear = [Total Sales]
VAR LastYear = CALCULATE([Total Sales], SAMEPERIODLASTYEAR('Date'[Date]))
RETURN DIVIDE(ThisYear - LastYear, LastYear)