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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ThingZy
Frequent Visitor

Looking for a way to calculate cumulative sum over many columns where the data is somewhat tricky.

I've been facing an issue when calculating cumulative sum and looking for alternative ways to do it.(other than unpviot columns)
The requirment is to get cumulative sum of values in all the months over few consecutive years and the issue is that when calculating cumulative sum the values of previous years(month-wise) are to be omitted(subtracted) in order to get the required result.

Here is a pic of the data sample and link to access the data : toffeeshare.com/c/9OUbuKo13W


C & R.png

The target is to showcase the cumulative sum from a ceratin date to a certain date in a 'Stacked area chart' like below :


graph.png

Knowing that this might require too many calculations to solve and get the required result, any reply is welcome!

1 ACCEPTED SOLUTION

@ThingZy Well, I would unpivot the month columns and rename the Attribute column to Month, then add a column like:

MonthSort = 
  SWITCH('Table'[Month],
    "Jan",1,
    "Feb",2,
    "Mar",3,
    // etc.
  )

This will make a cumulative total super easy. Better Running Total - Microsoft Power BI Community

 

Otherwise, without unpivoting you are going to have some nasty logic and I don't even know how you are going to construct an x-axis having all of your values in different columns. Ugly.

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@ThingZy What is the problem with unpivoting? Otherwise, it gets ugly.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

Hello Greg Deckler
The problem is not with unpivoting. Not sure but to obtain the solution it seems that things might get ugly like you have mentioned('Otherwise, it gets ugly')

I'd appriciate any suggestion

Thanks,

Soumith

 

@ThingZy Well, I would unpivot the month columns and rename the Attribute column to Month, then add a column like:

MonthSort = 
  SWITCH('Table'[Month],
    "Jan",1,
    "Feb",2,
    "Mar",3,
    // etc.
  )

This will make a cumulative total super easy. Better Running Total - Microsoft Power BI Community

 

Otherwise, without unpivoting you are going to have some nasty logic and I don't even know how you are going to construct an x-axis having all of your values in different columns. Ugly.

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.