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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.