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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Anonymous
Not applicable

Create Measure that shows Previous Period of period selected in Date Slicer

Good Day and thanks in advance for any help.

I am attempting to create a measure that finds Sales Revenue for the parallel period (for the previous year) selected in my Time Period selector.

 

To explain: I have a table that shows Market Classification, Revenue, Total Costs, Gross Profit and Gross Profit Rate. I have also a Time Period Slicer that changes all of the above values to Current Month to Date, Current Year to Date, MTD Last Year, YTD Last Year, etc. I am attempting to add another column that will compare the revenue in the selected time period with the revenue of the parallel period the prior year.

 

So if I select Current Quarter to Date from the selector, then I would like this new column to show QTD Revenue for 2019 .  I cannot figure out what measure to use to do this.

 

I am sorry I cannot share data for this, there is too much proprietary info to strip.

 

Thank you!

 

Time Period Selector 2.jpg

 Here is what I am trying to do:

time period selecto 3.JPG

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

We can try to use a all function in a measure to get correct result (by removing the period filter when calculate the last year):

 

Measure = CALCULATE('Sales'[Profit],ALL(Period[Period]),SAMEPERIODLASTYEAR('Calendar'[Date]))

 

2.jpg


If it doesn't meet your requirement, Could you please show the exact expected result based on the Tables that you have shared?


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

10 REPLIES 10
Greg_Deckler
Super User
Super User

Generally you wrap your measure in a CALCULATE and use SAMEPERIODLASTYEAR or PARRELPERIOD



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...
Anonymous
Not applicable

Hi @Greg_Deckler  Thanks! I have tried both and they are coming up blank. I have used:

 

= CALCULATE([REVENUE],PARALLELPERIOD('Calendar'{[Date],-1,YEAR))    and

= CALCULATE([REVENUE],SAMEPERIODLASTYEAR('Calendar'{Date])

 

Likely has to do with my Time Period table used for the slicer? I will try to get some data together quickly to show

Ah, yes, probably. You are probably not using a separate date table marked as a date table. That's when you can use time intelligence functions. 

 

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

 

I would need to understand your data better to figure out how to help specifically. Let me reread the post.



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...
Anonymous
Not applicable

@Greg_Deckler Here is a sample report, hopefully it helps/works!

 

Test Report 

It's a PBIT file so I it doesn't load any data other than calendar


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...
Anonymous
Not applicable

Yeahhhh I havent shared anything on here before so I figured I would do it wrong. Trying again! (thanks for being patient!)

 

Report Take 2 

OK, looking at this, perhaps you could do something like this:

 

 

Previous Year Revenue = 
  VAR __Min = MIN('Period'[Date])
  VAR __Max = MAX('Period'[Date])
  VAR __LastYearMin = DATE(YEAR(__Min)-1,MONTH(__Min),DAY(__Min))
  VAR __LastYearMax = DATE(YEAR(__Max)-1,MONTH(__Max),DAY(__Max))
RETURN
  SUMX(FILTER('Sales','Sales'[Time Entered] >= __LastYearMin && 'Sales'[Time Entered] <= __LastYearMax),'Sales'[Revenue])

 



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...
Anonymous
Not applicable

Ah no dice, still blank 😞

But thank you!

Hi @Anonymous ,

 

We can try to use a all function in a measure to get correct result (by removing the period filter when calculate the last year):

 

Measure = CALCULATE('Sales'[Profit],ALL(Period[Period]),SAMEPERIODLASTYEAR('Calendar'[Date]))

 

2.jpg


If it doesn't meet your requirement, Could you please show the exact expected result based on the Tables that you have shared?


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-lid-msft YES!! One change: the measure is for Revenue and not profit, but you got it. I tried something similar as well previously but had the syntax wrong and with all my other failed attempts had lost all hope. Thank you Thank you!

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors