cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
wsushox1
Helper II
Helper II

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

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

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

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

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 Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!