Forum Discussion
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
- Greg_DecklerCommunity Champion
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-TITHW/m-p/434008Also:
- lherbert501Post Prodigy
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
- Greg_DecklerCommunity Champion
lherbert501 My main point here is to not use SAMEPERIODLASTYEAR.
- lherbert501Post Prodigy
Greg_Deckler I'm using a bridge table to get to the date table. Could this be influencing it?
- Ashish_MathurSuper 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.