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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Usha_pk
Helper II
Helper II

How to show dynamic year based on selected year

Hi team,

 

I have a requirement for the dynamic year column where based on the selected year, it should show the previuos six years.

If the seleted year is 2030, then it should reflect 2024,2025,2026,2027,2028,2029.
If the selected year is 2029, it should show 2023,2024,2025,2026,2027,2028.

Can you please help on this. Thank you!
@tamerj1 @Ritaf1983 @Ahmedx @Greg_Deckler @amitchandak @Fowmy 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Usha_pk ,

Based on your problems, I created a simple table.

vyilongmsft_0-1707292906479.png

First of all I think you can create a Measure to fulfill your needs, you can have a try.

Dynamic Year = 
VAR SelectedYear = YEAR(TODAY())
RETURN
IF(
    VALUES('Year'[Date]) IN { SelectedYear, SelectedYear - 1, SelectedYear - 2, SelectedYear - 3, SelectedYear - 4, SelectedYear - 5 },
    1,
    0
)

You can also select New group under Slicer.

vyilongmsft_1-1707293599197.png

vyilongmsft_2-1707294013378.png

This will also give you the results you're looking for.

vyilongmsft_3-1707294158491.png

 

 

 

Best Regards

Yilong Zhou

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

4 REPLIES 4
Anonymous
Not applicable

Hi @Usha_pk ,

Based on your problems, I created a simple table.

vyilongmsft_0-1707292906479.png

First of all I think you can create a Measure to fulfill your needs, you can have a try.

Dynamic Year = 
VAR SelectedYear = YEAR(TODAY())
RETURN
IF(
    VALUES('Year'[Date]) IN { SelectedYear, SelectedYear - 1, SelectedYear - 2, SelectedYear - 3, SelectedYear - 4, SelectedYear - 5 },
    1,
    0
)

You can also select New group under Slicer.

vyilongmsft_1-1707293599197.png

vyilongmsft_2-1707294013378.png

This will also give you the results you're looking for.

vyilongmsft_3-1707294158491.png

 

 

 

Best Regards

Yilong Zhou

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

Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your semantic model looks like, but I tried to create a sample pbix file like below.

Please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1707201719956.png

 

Jihwan_Kim_1-1707201980947.png

WINDOW function (DAX) - DAX | Microsoft Learn

 

Sales measure: = 
SUM( Sales[Sales] )

 

Sales last 6 years: =
VAR _t =
    WINDOW ( -5, REL, 0, REL, ALL ( Period[Year] ), ORDERBY ( Period[Year], ASC ) )
VAR _condition =
    COUNTROWS ( _t ) = 6
RETURN
    IF ( _condition, CALCULATE ( [Sales measure:], _t ) )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

@Jihwan_Kim 

Thanks for your reply. But this is not exactly my requirement. Let me explain you clearly.
I need a dynamic year column, where based on the year selected it should reflect the previous six years.

For example:
If selected year is 2028, then the dynamic year should be 2022, 2023, 2024, 2025, 2026, 2027

Thank you!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors