Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rainchong7401
Helper III
Helper 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 show 2019.

rainchong7401_1-1669092883090.png

 

1 ACCEPTED SOLUTION

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()
)

View solution in original post

6 REPLIES 6
KNP
Super User
Super 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?

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

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()
)
Analystmate
Helper II
Helper II

As far as I know, Changing the field name dynamically feature is not available.

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()
)

 

FreemanZ
Super User
Super User

Add a new measure with the code below?

PreviousYear = SELECTEDVALUE(TableName[Year])+1

Hi FreemanZ,
This is not what I want.
I mean I want to have dynamics year based on my selection.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.