Forum Discussion
How to Determine Same Period Specific Year
Hello,
Just as SAMEPERIODLASTYEAR can change the context of a measure to parallel dates last year, is there a way that I can calculate a meaure in the context of a very specific year -- e.g. 2019?
This means the meaure would work exactly as SAMEPERIODLASTYEAR, adjusting to all filter contexts, except that it would be relative to the specific year.
Hey jmeccles ,
yes, you can use the function PARALLELPERIOD to get an individual period.
So you could do:
MyParallelMeasure = CALCULATE( [MyMeasure], PARALLELPERIOD( Datetable[Date], -2, YEAR ) )If you need any help please let me know.If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍Best regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic
5 Replies
- mahoneypat
Microsoft Employee
You can dynamically calculate the years from 2019 in a variable ( e.g., YEAR(MAX(Date[Date])) - 2019 ), and then use that within PARALLELPERIOD inside a CALCULATE as suggested by selimovd
Pat
- AnonymousNot applicable
Thanks for the tip with the dynamic calculation mahoneypat - I had to create a negative value for the interval, and I used DATEADD (for some reason PARALLELPERIOD returned a BLANK value).
Anyway, this is what it looks like for me, in case it helps anyone:
DATEADD ( DateTable[Date],
CALCULATE ( ( YEAR ( MAX ( DateTable[Date] ) ) - 2019 ) * ( -1 ) ),
YEAR )This creates a dynamic time interval, always referencing back from the current date to the same period in 2019. Very handy for "Pre-COVID19" calculations.
- MihailRegular Visitor
This is brilliant. But can you do the same with Same Day of Week ? instead of Date vs Date ? Please help.
- selimovd
Most Valuable Professional
Hey jmeccles ,
yes, you can use the function PARALLELPERIOD to get an individual period.
So you could do:
MyParallelMeasure = CALCULATE( [MyMeasure], PARALLELPERIOD( Datetable[Date], -2, YEAR ) )If you need any help please let me know.If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍Best regardsDenisBlog: WhatTheFact.biFollow me: twitter.com/DenSelimovic