cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
wsushox1 Frequent Visitor
Frequent Visitor

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

Accepted Solutions
amitchandak Super Contributor
Super Contributor

Re: Last Year QuarterEnd Sales

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 Contributor
Super Contributor

Re: Last Year QuarterEnd Sales

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

wsushox1 Frequent Visitor
Frequent Visitor

Re: Last Year QuarterEnd Sales

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
New Topics Started Badges Coming

New Topics Started Badges Coming

We're releasing new versions of the badge that everyone's talking about. ;) Check your inbox for notifications.

MBAS 2020

Save the new date (and location)!

Our business applications community is growing—so we needed a different venue, resulting in a new date and location. See you there!

Difinity Conference

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

Top Solution Authors
Top Kudoed Authors (Last 30 Days)