cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
wes-shen-poal
Helper III
Helper III

How to calculate measure for same period 2 years ago

Hi there,

 

I use SAMEPERIODLASTYEAR() to calculate measure for same period 1 year ago.

 

How do I do it for same period 2 years ago?


Thanks,

Wes

1 ACCEPTED SOLUTION
vanessafvg
Super User
Super User

@wes-shen-poal measurename = calculate(measure, parallelperiod(datetable[date], -2, year))

 

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




View solution in original post

9 REPLIES 9
kalpesh07
New Member

I Just found a better way to do it + It work dynamically based on user selection (not just on Only Year or Month or Days)

 

I've just nested Sameperiodlastyear

 

So for same period 2 year ago it will be like :

Syntax : SAMEPERIODLASTYEAR(SAMEPERIODLASTYEAR([Date])) 

jveroes_rhc
Frequent Visitor

(edited)
I tried the suggested PARALLELPERIOD function and it skewed dates and values. You can test by just comparing the calc field with one year only using SAMEPERIODLASTYEAR and PARALLELPERIOD.

What has worked for me was DATEADD, so, the mesuare will look like:
measureName =calculate(measure, DATEADD(datetable[date], -2*364, DAY))


This way at least you compare the "same weekday", could be not in the same month but that is what I was after. Use @Anonymous but with DATEADD() suggestion below for other usecases.

I know is 5 yrs ago the question, but worth the contribution!

Regards

Jose

This was the one that worked for me!
My month selection in my slicer is dynamic, so this let me compare historical YTD numbers (parallelperiod would only give me prior full years)

Thanks!

Anonymous
Not applicable

Good to be mindful of what period type you have in your report.

If you want to see the whole of the year for two years ago then the  prior solution is perfect

    calculate(measure, parallelperiod(datetable[date], -2, year))

 

However, if the report is a month by month one then try 

     calculate(measure, parallelperiod(datetable[date], -24, month))

Hi, I have tried your advice but I'm getting the error message below. Can you tell me what I'm missing? Thanks!

RenataOGardner_0-1620558147349.png

 

Are you missing the DATEADD function?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

@RenataOGardner 

Please try

CALCULATE ([Net Sale TY], PARALLELPERIOD('Date'[Date], - 24,MONTH))

I think You need to include the PARALLELPERIOD function name and also a comma before the -24

Please let me know how you go

vanessafvg
Super User
Super User

@wes-shen-poal measurename = calculate(measure, parallelperiod(datetable[date], -2, year))

 

 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Thank you @vanessafvg

Helpful resources

Announcements
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

MPPC 2023 PBI Carousel

Power Platform Conference-Power BI and Fabric Sessions

Join us Oct 1 - 6 in Las Vegas for the Microsoft Power Platform Conference.

Top Solution Authors