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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Alvin2013
Frequent Visitor

How to do a running total sorted by values

How to create a running total that follow the order of my chart?

Alvin2013_0-1686460505491.png

This was done in Tableau. How to replicate it in PowerBI?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Alvin2013 ,

 

I suggest you to try code as below to create a measure.

Running Total Sort by Values =
VAR _SUMMARIZE =
    SUMMARIZE ( ALL ( 'Table' ), 'Table'[Category], "Sum", SUM ( 'Table'[Value] ) )
VAR _ADDSORT =
    ADDCOLUMNS ( _SUMMARIZE, "Sort", RANKX ( _SUMMARIZE, [Sum],, DESC, SKIP ) )
VAR _RUNNINGTOTAL =
    ADDCOLUMNS (
        _ADDSORT,
        "Running Total", SUMX ( FILTER ( _ADDSORT, [Sort] <= EARLIER ( [Sort] ) ), [Sum] )
    )
RETURN
    SUMX (
        FILTER ( _RUNNINGTOTAL, [Category] = MAX ( 'Table'[Category] ) ),
        [Running Total]
    )

Result is as below.

vrzhoumsft_0-1686623198609.png

 

Best Regards,
Rico Zhou

 

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 @Alvin2013 ,

 

I suggest you to try code as below to create a measure.

Running Total Sort by Values =
VAR _SUMMARIZE =
    SUMMARIZE ( ALL ( 'Table' ), 'Table'[Category], "Sum", SUM ( 'Table'[Value] ) )
VAR _ADDSORT =
    ADDCOLUMNS ( _SUMMARIZE, "Sort", RANKX ( _SUMMARIZE, [Sum],, DESC, SKIP ) )
VAR _RUNNINGTOTAL =
    ADDCOLUMNS (
        _ADDSORT,
        "Running Total", SUMX ( FILTER ( _ADDSORT, [Sort] <= EARLIER ( [Sort] ) ), [Sum] )
    )
RETURN
    SUMX (
        FILTER ( _RUNNINGTOTAL, [Category] = MAX ( 'Table'[Category] ) ),
        [Running Total]
    )

Result is as below.

vrzhoumsft_0-1686623198609.png

 

Best Regards,
Rico Zhou

 

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

Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

Top Solution Authors
Top Kudoed Authors