Forum Discussion
The dreaded "SAMEPERIODLASTYEAR" Function
Hi Guys - I was wondering if someone could perhaps help.... I've spent a day on this, read just about every forum post, but I'm clearly missing something in relation to the SAMEPERIODLASTYEAR function.
Details:
I have a Transaction DB - Consumed into PowerBi via Odata
I have a seperate Calendar DB I created in PowerBi (Well formed)
On the transaction DB - I have created the following measures:
Sum of Sales --> Sum of Sales = SUM (Transactions[amount])
Year to Date Sum of Sales --> YTDSumOfSales = TOTALYTD([Sum of Sales],'CALENDAR'[Date])
Last Year Sales --> SalesLastYTD = CALCULATE([YTDSumOfSales], SAMEPERIODLASTYEAR('CALENDAR'[Date]))
For some reason the Last Year Sales Measure is moving the measure ahead; instead of behind (IE - 2018, insted of 2016) - Here is what the table of the data looks like the below.
Essentially I am trying to create some KPI Scorecards to show you how you are trading against Last YTD / Last MTD / Last WTD / This Week vs Last Year This Week / Today vs Today Last Year.
Any direction would be well recieved!
Not sure what you mean. Results look as expected. 2017 SalesLastYTD is showing 2016 YTDSumOfSales, etc.
2 Replies
- mattbriceSolution Sage
Not sure what you mean. Results look as expected. 2017 SalesLastYTD is showing 2016 YTDSumOfSales, etc.
- RobbiefHelper II
Thanks for pointing out the obvious to me. I ended up going in circles; and getting confused with the Sameperiodlastyear / parrallelperiod / dateadd..... But I realised I was being stupid, and after reading a few more articles, i figured it out.
This really helped:
https://www.kasperonbi.com/powerpivot-dax-parallelperiod-vs-dateadd/