cancel
Showing results for
Did you mean:
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:

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

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 !!
2 REPLIES 2
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

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 !!
Helper II

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.

Announcements

#### 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 Design Challenge

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

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