To convert the column formula into a measure, simply replace the first three lines of code with the following:
VAR __Month = MAX('R06_Table'[Month])
VAR __Year = MAX('R06_Table'[Year])
VAR __Revenue = MAX('R06_Table'[Revenue YTD])
We can also demonstrate how to calculate the YTD revenue for a month if we're given the periodic revenue for each month. To do this, create a column in the R06_Table table using the following formula:
YTD Revenue =
SUMX(
FILTER(
ALL('R06_Table'),
'R06_Table'[Year] = EARLIER('R06_Table'[Year]) &&
'R06_Table'[Month] <= EARLIER('R06_Table'[Month])
),
[Periodic Revenue]
)
This formula demonstrates a different method of referring to the current row's Month and Year column values, as well as a different method of calculating the sum of the returned rows from our FILTER function. In this case, we use the EARLIER function to reference the current row's Month and Year column values and use the SUMX function instead of the CALCULATE and SUM functions.