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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
lherbert501
Post Patron
Post Patron

SAMEPERIODLASTYEAR Months Selected

Hi,

 

Could somebody please help me with my dax to get sameperiodlastyear but to match whatever is selected in the slicer?

 

The slicer is at month/period level. E.G if I select December 2023 I want to see all from December 2022. If I select Oct,Nov,Dec 2023 I want the same calculation for the same 3 months, the year before.

 

I have the total measure and date calender set up. All of my data is in YYYYMM format but I do have a calender table.

 

Thanks

 

Liam

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Assuming that the month slicer has been built from the Calendar Table and you have already set up a proper relationship, write this measure

Measure = calculate([Sales],sameperiodlastyear(calendar[date]))

Hope this helps. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Super User
Super User

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

 

Also:



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  I'm using a bridge table to get to the date table. Could this be influencing it?

Hi @Greg_Deckler 

 

Thanks. I've tried to match your pbix but  SAMEPERIODLASTYEAR just wont have it when I'm only dealing in periods and months it seems

@lherbert501 My main point here is to not use SAMEPERIODLASTYEAR.



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!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.