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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

cumulative sum based on three columns

Hello everyone,

         Below is my sample data.

ITEM        CATEGORY    DATE              AMOUNT        RUNNING TOTAL

1              c1                 1/1/2020             100                 100

1              c1                 2/1/2020             150                 250

1              c2                 1/1/2020             200                 200 

1              c3                 2/1/2020             150                 150

2              c1                 2/1/2020             200                 200

2              c2                 1/1/2020             250                 250

2              c3                 1/2/2020             100                 100

2              c3                 2/2/2020             150                 250

 

The last calculated column named running total is what my requirement. I need to create cumulative amount column based on 3 columns(item,category,date). First i need to filter item column and then category, to calculate the sum of amount according to 'table1'[date]<=EARLIER('table1'[date]) in ascending order. Most import thing is my report page will only have date slicer, item and category slicer will not be presented. My visual is a table visual.

 

Thanks in advance....

 

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous 

Try as column

cumm column= sumx(filter(Table, [ITEM] = earlier([ITEM]) && [CATEGORY] = earlier([CATEGORY]) && [DATE] <= earlier([DATE]) ),[AMOUNT])

 

As measure

cumm measure= sumx(filter(allselected(Table), [ITEM] = max([ITEM]) && [CATEGORY] = max([CATEGORY]) && [DATE] <= max([DATE]) ),[AMOUNT])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Fowmy
Super User
Super User

@Anonymous 

Add as a new Column:

Cumm = 
var i = [ITEM ]
var cat = [CATEGORY ]
var _date = [DATE ] 
return
CALCULATE(
    SUM('Table'[AMOUNT ]),
    'Table'[ITEM ] = i,
    'Table'[CATEGORY ] = cat,
    'Table'[DATE ] <= _date,
    ALL('Table')
)



________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

@amitchandak  @Fowmy 

thanks to both you,

All your dax expressions are working fine.

Fowmy
Super User
Super User

@Anonymous 

Add as a new Column:

Cumm = 
var i = [ITEM ]
var cat = [CATEGORY ]
var _date = [DATE ] 
return
CALCULATE(
    SUM('Table'[AMOUNT ]),
    'Table'[ITEM ] = i,
    'Table'[CATEGORY ] = cat,
    'Table'[DATE ] <= _date,
    ALL('Table')
)



________________________

Did I answer your question? Mark this post as a solution, this will help others!.

Click on the Thumbs-Up icon on the right if you like this reply 🙂

YouTube, LinkedIn

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

amitchandak
Super User
Super User

@Anonymous 

Try as column

cumm column= sumx(filter(Table, [ITEM] = earlier([ITEM]) && [CATEGORY] = earlier([CATEGORY]) && [DATE] <= earlier([DATE]) ),[AMOUNT])

 

As measure

cumm measure= sumx(filter(allselected(Table), [ITEM] = max([ITEM]) && [CATEGORY] = max([CATEGORY]) && [DATE] <= max([DATE]) ),[AMOUNT])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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