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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Cumulative sum based on text

Here is my table and I have the first three columns and I am trying to calculate the 3rd column which is cumulative sum though i have dates in the bigger table i just want this small table irrespective of the dates based on Type.'

 

type total cumsum

abc  32      32

def   33      65

ghi   34     99

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Anonymous,

Here are two ways to provide you:

 

一.

1.Power Query generate index column.

2.Create a measure.

Measure = CALCULATE(SUM('Table'[total]),FILTER(ALLSELECTED('Table'),'Table'[Index]<=MAX('Table'[Index])))

3.Result

v-yangliu-msft_0-1604914370384.jpeg

二.

1.Create a calculated column.

Column = CALCULATE(SUM('Table'[total]),FILTER(ALLSELECTED('Table'),'Table'[type]<=EARLIER('Table'[type])))

2.Result.

v-yangliu-msft_1-1604914370387.jpeg

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @Anonymous,

Here are two ways to provide you:

 

一.

1.Power Query generate index column.

2.Create a measure.

Measure = CALCULATE(SUM('Table'[total]),FILTER(ALLSELECTED('Table'),'Table'[Index]<=MAX('Table'[Index])))

3.Result

v-yangliu-msft_0-1604914370384.jpeg

二.

1.Create a calculated column.

Column = CALCULATE(SUM('Table'[total]),FILTER(ALLSELECTED('Table'),'Table'[type]<=EARLIER('Table'[type])))

2.Result.

v-yangliu-msft_1-1604914370387.jpeg

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mahoneypat
Microsoft Employee
Microsoft Employee

To do a cumulative sum you will need a column that changes over time, like a Date column or an index column.  If you don't have one, you can add an Index column in the query editor on the Add column tab.  You can then use a measure expression like this to get cumulative sum.

 

CumulativeSum = var thisindex = Table[Index] // or use your Date column in a similar way

return CALCULATE(SUM(Table[Total]), all(Table[Index]), Table[Index]<= thisindex)

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors