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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Last Year QuarterEnd Sales

Hello,

 

I have what I believe to be a straight forward DAX problem that I have tried for several days to scour the internet and tinker in PowerBI to solve.

 

I am trying to get the value for the previous year's quarter end sales for the current quarter. So for example, I want to calculate last years cumulative yearly sales up until 12/31/2018 (our FY starts 07/01). I feel as if I am very close to accomplishing this.

 

This is how I have my current date table set-up:

date table.PNG

 

The date table goes from 7/1/1999 until 7/1/2020. The isPast column returns True if it "is Past" the date 1 year ago from today.  The isPastCurrentFY returns "True" if it is past today's date (values True from 12/9/2019 and back).

 

I currently have the following measures to get YTD Sales, and PYTD Sales (comp sales):

 

 

 

YTDSales= TOTALYTD(COUNT('20YearNMs'[Reference ID]), dateDim[Date], "06/30")

PYTD Sales= CALCULATE([YTDSales], SAMEPERIODLASTYEAR(dateDim[Date]),'dateDim'[isPast] = True)

 

 

 

I also have a measure that returns the last date of last years quarter for the current quarter we are in. In this case, the measure below returns 12/31/2018 12:00AM

 

LYQuarterEnd = CALCULATE(ENDOFQUARTER(dateDim[Date]), dateDim[isPast] == True)

 

I then try to calculate last years sales from start of FY to the current quarter end (end of Q2) with this measure:

 

 

 

QuarterlySalesrGoal = CALCULATE([YTDSales], SAMEPERIODLASTYEAR(dateDim[Date]), FILTER(dateDim,dateDim[Date] <= [LYQuarterEnd]))

 

 

However, the quarterly sales goal gives me the exact same number as the "PYTD Sales" measure.  Why is this happening? Why isn't it giving me sales from 07/01/2018 to 12/31/2018? Is it because of the SAMEPERIODLASTYEAR code? How can I work around this?

 

Any help would be appreciated. I'm just confused on how to navigate this problem.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

You can try

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date Filer])))

Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date Filer],-1,QUARTER)))

Last year same QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date Filer],-1,Year)))

 

or, this should also QOY

Last Year Sales = CALCULATE(TOTALYTD(sum(Sales[Sales Amount]),dateadd('Date'[Date Filer].-12,month)))

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

You can try

QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(('Date'[Date Filer])))

Last QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date Filer],-1,QUARTER)))

Last year same QTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESQTD(dateadd('Date'[Date Filer],-1,Year)))

 

or, this should also QOY

Last Year Sales = CALCULATE(TOTALYTD(sum(Sales[Sales Amount]),dateadd('Date'[Date Filer].-12,month)))

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks.

My Recent Blog - https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Anonymous
Not applicable

Thank you for this!

 

I actually think my measure and method worked fine. We just didn't have any sales after 12/9 of last year (not a holiday sensitive company) so that is why the QuarterEnd Sales and Previous YTD sales were the same haha.

 

If my measures don't work once Q3 starts on January 1 I will use your measures. Accepted as solution and Kudosed.

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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