Forum Discussion
rainchong7401
3 years agoHelper III
Add Dynamic Year in Column Name
Hi Friends, Is it possible to add year in column name? So it change dynamically based on the year selection. If I select 2021, prev year column show 2020, If I select 2020, prev year column s...
- 3 years ago
Hi,
It's possible to do it.
I've done it already.CURPREV_YEAR = VAR Sales = CALCULATE([TOTAL_QTY],DATETABLE[YEAR] = SELECTEDVALUE('YEAR'[YEAR])) return IF( SELECTEDVALUE('YEAR'[YEAR]) IN {MAX(DATETABLE[YEAR]),MAX(DATETABLE[YEAR])-1},Sales,BLANK() )
KNP
3 years agoSuper User
There are probably a few different ways to solve this.
Just need some extra detail.
If I was to select 2021 from the slicer, are you only wanting to see 2020, or do you expect to see everything AFTER 2020?
rainchong7401
3 years agoHelper III
Hi,
It's possible to do it.
I've done it already.
CURPREV_YEAR =
VAR Sales = CALCULATE([TOTAL_QTY],DATETABLE[YEAR] = SELECTEDVALUE('YEAR'[YEAR]))
return
IF(
SELECTEDVALUE('YEAR'[YEAR]) IN {MAX(DATETABLE[YEAR]),MAX(DATETABLE[YEAR])-1},Sales,BLANK()
)