DATEADD and MAX?
Hi,
I understand that the below filter function returns a table containing all dates in the date table and where the latest date in that table is defined by the filter context. Thus, if the date table contains all dates between 2000 and 2024 and the filter context is 2023, the below function will return a table with all dates between 2000-2023.
FILTER(
ALL(Dates),
Dates[Date] <= MAX(Dates[Date])
)
However, if I want (for the very same filter context, that is, 2023) to return a table will all dates between 2000-2022, I guess I can modify the above function so it instead reads:
FILTER(
ALL(Dates),
Dates[Date] <= MAX(Dates[Date]) - 365
)
But there should be some more elegant solution using DATEADD or SAMEPERIODLASTYEAR instead, something like below but I don't get it to work. I assume this is super simple, but for now I got stuck...
FILTER(
ALL(Dates),
Dates[Date] <= DATEADD(MAX(Dates[Date]), -1, YEAR)
)