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
RohiniP-26
Resolver I
Resolver I

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

@RohiniP-26 

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])

View solution in original post

Fowmy
Super User
Super User

@RohiniP-26 

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
RohiniP-26
Resolver I
Resolver I

@amitchandak  @Fowmy 

thanks to both you,

All your dax expressions are working fine.

Fowmy
Super User
Super User

@RohiniP-26 

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

@RohiniP-26 

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])

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