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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Sergi
Frequent Visitor

Create a dynamic row for years

Hi,

 

hope some one suport, I would like to have a dynamic row based on the years, which should change automatically over the years.

Example:

Row    Forecast    Year

1         Actual        2021

2         LY              2020

3         LY-1          2019

4         LY-2          2018

 

for next year should be:

Row    Forecast    Year

1         Actual        2022

2         LY              2021

3         LY-1          2020

4         LY-2          2019

 

thanks,

 

Sergi

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @Sergi ,

 

According to your description, it seems you want to display last 3 years based on current date.

If so, please enter a table firstly and then create a measure:

Eyelyn9_1-1636358982097.png

Measure = 
var _yearToday=YEAR(TODAY())
return
SWITCH(MAX('NewTable'[Forecast]),"Actual",_yearToday,"LY",_yearToday-1, "LY-1",_yearToday-2, "LY-2",_yearToday-3)

Output:

Eyelyn9_2-1636359006755.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-eqin-msft
Community Support
Community Support

Hi @Sergi ,

 

According to your description, it seems you want to display last 3 years based on current date.

If so, please enter a table firstly and then create a measure:

Eyelyn9_1-1636358982097.png

Measure = 
var _yearToday=YEAR(TODAY())
return
SWITCH(MAX('NewTable'[Forecast]),"Actual",_yearToday,"LY",_yearToday-1, "LY-1",_yearToday-2, "LY-2",_yearToday-3)

Output:

Eyelyn9_2-1636359006755.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

VahidDM
Super User
Super User

Hi @Sergi 

 

Can you share a sample of your data table?
BTW, Try this:

 

Row = 
Var _Y = Year(Today())
Var _MY = MAX(table[year])
return
_Y-_MY+1

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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