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
rsbin
Super User
Super User

Cumulative Totals: Last Year vs Current Year

Good Evening,

Working with cumulative totals and having a hard time figuring out my last step.

I want to chart Cumulative Volumes for all of 2019 and then Cumulative volume YTD for 2020

I have been able to create Cumulative Volume for my entire data set as below:

 

 

Cumulative Volume = CALCULATE( [Total Volume],
                      FILTER(ALLSELECTED('Calendar'),
                      'Calendar'[Date] <= MAX('Calendar'[Date] )))

 

 I haven't been able to figure out how to separate running totals for  2019 from 2020.  I figure it should be fairly simple.

  I have [Year] in my 'Calendar' table but unable to get my FILTER syntax worked out.

Leaning for some assistance from the Community. 

 

Best Regards and hope everyone is keeping safe!

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@sevenhills , YTD, using datesytd or total YTD can serve the purpose

Example

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

 

No need for Last YTD , as ytd will reset itself at year-end

or Try your formula like

Cumulative Volume = CALCULATE( [Total Volume],
                      FILTER(ALLSELECTED('Calendar'),
                      'Calendar'[Date] <= MAX('Calendar'[Date] && year('Calendar'[Date]) = Year(MAX('Calendar'[Date]) )))

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

Select 2020 in the Year slicer (which should be from the Calendar Table).  To your visual, drag Month name from the Calendar Table.  Try this measure:

=calculate([Total volume],datesytd(calendar[date],"31/12"))

Hope this helps.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@sevenhills, @amitchandak , @Ashish_Mathur 

Thank you all for the responses.   All of the new suggestions work as intended.

rsbin_0-1602940051675.png

Now, my next step is to turn Oct - Dec 2020 (green line) into a budget line.  I believe I have found a thread that describes how to do that.

Again, thank you all and best regards!

 

amitchandak
Super User
Super User

@sevenhills , YTD, using datesytd or total YTD can serve the purpose

Example

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))

 

No need for Last YTD , as ytd will reset itself at year-end

or Try your formula like

Cumulative Volume = CALCULATE( [Total Volume],
                      FILTER(ALLSELECTED('Calendar'),
                      'Calendar'[Date] <= MAX('Calendar'[Date] && year('Calendar'[Date]) = Year(MAX('Calendar'[Date]) )))

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

sevenhills
Super User
Super User

 

Cumulative Volume = CALCULATE( [Total Volume],
                      FILTER(ALLSELECTED('Calendar'),
                      'Calendar'[Date] <= MAX('Calendar'[Date] )
                      && ( 'Calendar'[Year] = 2019 || 'Calendar'[Year] = 2020)
                      )
                     )

 

@sevenhills 

Thanks much for the reply.   Formula works, but not quite what I need. 

I need to reset 2020 Volume to 0 and start my cumulative total again.    The two line charts should almost line up...of course until Sept which is the last month in my data.
Any idea on how to modify your dax to achieve this?

 

 

rsbin_0-1602893015588.png

 

Thanks again for the quick reply.  Much appreciated!

Provide the data sample ... as I dont see Volume in your first formula.

 

 

I am thinking what you need is DATESYTD, I may be wrong

 

Check this article: https://www.sqlbi.com/articles/computing-running-totals-in-dax/

 

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.

Top Solution Authors