Forum Discussion
DAX Issue.
Anonymous do you have a DimDate table? Is that what Query2 is?
You can do this more easily if you have a DimDate table using built in time intelligence, otherwise you need to calculate the max selected year in the context of the entire report, you can do this using a variable, but does it need to work for multiple year selections? If so, DimDate table is much easier. https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html
Otherwise, using a variable would look something like (I have tried to account for multiple year selections, and imitated behaviour of the DATEADD function using time intelligence and date table:
Test =
VAR maxYear = MAX(Query2[RPTyear])
VAR minYear = MIN(Query2[RPTyear])
RETURN
CALCULATE(SUM(Query[Jan]),FILTER(ALL(Query2[RPTyear]), Query2[RPTyear]<= maxYear-1 && Query2[RPTyear]>= minYear-1 ))