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
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
Super User
Super User

@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...


@ 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!:
The Definitive Guide to Power Query (M)

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
Super User
Super User

@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...


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.