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
sanjeev803
Helper I
Helper I

Cumulative Sum across years by category

Hi -  I have data for four years. I need a cumulative sum and cumulative percentage across years by sub-category.

 

sample data:

Sub-CategoryTotal Qty
Binders5818
Paper5035
Furnishings3484
Phones3220
Storage3075
Accessories2911
Art2883
Chairs2295
Appliances1706
Labels1358
Tables1212
Envelopes891
Fasteners888
Bookcases837
Supplies643
Machines424
Copiers234

 

I need output like this:

Sub-CategorySum of QuantityCsumCsum%
Binders5818581816%
Paper50351085329%
Furnishings34841433739%
Phones32201755748%
Storage30752063256%
Accessories29112354364%
Art28832642672%
Chairs22952872178%
Appliances17063042782%
Labels13583178586%
Tables12123299789%
Envelopes8913388892%
Fasteners8883477694%
Bookcases8373561396%
Supplies6433625698%
Machines4243668099%
Copiers23436914100%

 

Any help of this highly appreciated.

 

Thanks,

Sanj

 

1 ACCEPTED SOLUTION

@sanjeev803 try following measures:

 

1st measure - create sum of qty

2nd measure - cummulative sum 

3rd measure - create grand total of qty for %

4th measure - create %

 

Sum = SUM( Table2[Total Qty] )

Sum Cummulative = 
IF( 
    HASONEVALUE( Table2[Sub-Category] ),  
    SUMX( FILTER( ALL( Table2 ), Table2[Total Qty] >= MAX( [Total Qty] ) ), [Sum] ),
    [Sum]
)

Sum Total = CALCULATE( [Sum], ALL( Table2[Sub-Category] )  )

Sum % = DIVIDE( [Sum Cummulative], [Sum Total] )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

2 REPLIES 2
HotChilli
Super User
Super User

Add an Index in Power Query Editor.

Create a measure as follows

CSum = CALCULATE(SUM(Table[Total Qty]), FILTER(ALL(Table), Table1[Index] <= MAX(Table[Index])))

Drag the measure on to the table visualisation twice. 

The second one --> right-click in the Values well and choose 'Show value as -> Percent of grand total'

@sanjeev803 try following measures:

 

1st measure - create sum of qty

2nd measure - cummulative sum 

3rd measure - create grand total of qty for %

4th measure - create %

 

Sum = SUM( Table2[Total Qty] )

Sum Cummulative = 
IF( 
    HASONEVALUE( Table2[Sub-Category] ),  
    SUMX( FILTER( ALL( Table2 ), Table2[Total Qty] >= MAX( [Total Qty] ) ), [Sum] ),
    [Sum]
)

Sum Total = CALCULATE( [Sum], ALL( Table2[Sub-Category] )  )

Sum % = DIVIDE( [Sum Cummulative], [Sum Total] )


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.