cancel
Showing results for
Did you mean:

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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.

1 ACCEPTED SOLUTION
Helper III

Hi,
It's possible to do it.

``````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()
)``````
6 REPLIES 6
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 ;).

 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. Proud to be a Super User!
Helper III

Hi,
It's possible to do it.

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

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

Helper III

Hi,
It's possible to do it.

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

Super User

Add a new measure with the code below?

PreviousYear = SELECTEDVALUE(TableName[Year])+1

Helper III

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

Announcements

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

#### Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

#### Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors