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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
id013
Helper V
Helper V

Is it possible to do sameperiodlastyear for dynamic years

Hi,

 

I am looking to create a year over year comparison but based on the same date range. Basically I will have a selection date range which will take place in the current year, and I want to be able to show calculations for this year, as well as the sameperiod in a different variable year? So for example if I select the selection date range of Jan 30 2020 to Mar 28 2020, I want to be able to select another year say 2017, and it will show me the values for Jan 30 2017 to Mar 28 2017. I suspect this will be complicated but I want to check if it's possible and if I even want to attempt it.

 

Thanks 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@id013 Probably some way using DATESINPERIOD perhaps or something else like that. Generally though, once you start to stray outside the lines a bit T"I" functions become more of a hassle than a help. 

 

You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Fowmy
Super User
Super User

@id013 

You can create a YearTable like below and provide a slider on the Year

YearYearNo
2018-1
2017-2
2016-3
2015-4
2014-5
2013-6


Then use the measure to calculate :

 

Measure = 
CALCULATE(
    [Total Sales],
    DATEADD('DATE'[Date], SELECTEDVALUE('YearTable'[YearNo]),YEAR)
)

 

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Greg_Deckler
Community Champion
Community Champion

@id013 Probably some way using DATESINPERIOD perhaps or something else like that. Generally though, once you start to stray outside the lines a bit T"I" functions become more of a hassle than a help. 

 

You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.

Users online (4,954)