At the moment I create a measure marketprice
for different years as the following:
marketprice 2021 = CALCULATE(LASTNONBLANKVALUE(table[column1],
SUMMARIZE(FILTER(table, table[year] = 2021), table[column1])))
marketprice 2022 = CALCUALTE(........)
marketprice 2023 = CALCUALTE(........)
marketprice 2024 = CALCUALTE(........)
But this is not dynamic because next year (2023) I only need the market prices from the years 2022, 2023, 2024, 2025 (in DAX syntax: YEAR(TODAY())-1
, YEAR(TODAY())
, YEAR(TODAY())+1
, YEAR(TODAY())+2
). I don't want to change every year the measure names and year-input in the measure calculation.
I hope this is possible.
You cant create dynamic name of measure instead you could try this with dynamic calculation:-
marketprice_previous_year =
CALCULATE (
LASTNONBLANKVALUE (
table[column1],
SUMMARIZE (
FILTER ( table, table[year] = YEAR ( TODAY () ) - 1 ),
table[column1]
)
)
)
marketprice_current_year =
CALCULATE (
LASTNONBLANKVALUE (
table[column1],
SUMMARIZE ( FILTER ( table, table[year] = YEAR ( TODAY () ) ), table[column1] )
)
)
marketprice_next_year =
CALCULATE (
LASTNONBLANKVALUE (
table[column1],
SUMMARIZE (
FILTER ( table, table[year] = YEAR ( TODAY () ) + 1 ),
table[column1]
)
)
)
marketprice_next_to_next_year =
CALCULATE (
LASTNONBLANKVALUE (
table[column1],
SUMMARIZE (
FILTER ( table, table[year] = YEAR ( TODAY () ) + 2 ),
table[column1]
)
)
)