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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
chsardas
Regular Visitor

Running total with ranking

Hi,

I'm trying to do a Running Total based on a rank of a measure.

 

After a little of research i've found the way to do the running total but i'm having a trouble with that.

 

I create a rank measure:

Ranking City = 
RANKX(ALL(Sales[City]),[QTR Quantity],,DESC,Skip)

 

And a measure for the running total:

Running Total = 
CALCULATE (
[QTR Quantity],
( TOPN ( [Ranking City], ALL ( Sales[City] ), [QTR Quantity] ) ))

 

The problem is when a pair of cities have the same rank (a tie situation) the running total sum the value of both cities in the same row / point (when it's a chart).

 

Example:Capture.PNG

I think the solution is try to change the ranking so when there's a tie it should put different ranking for each member.

 

Thanks!

1 ACCEPTED SOLUTION

Finnally i´ve got the solution.

 

I´ve changed the approach of the formula.

 

Used this guide (it´s in spanish)

 

https://www.pbiusergroup.com/blogs/victor-velarde/2017/07/07/como-realizar-un-diagrama-8020-o-de-dis...

View solution in original post

9 REPLIES 9
Zubair_Muhammad
Community Champion
Community Champion

Hi @chsardas

 

Could you try this?

 

Running Total =
CALCULATE (
    [QTR Quantity],
    (
        TOPN (
            [Ranking City],
            ALL ( Sales[City] ),
            [QTR Quantity]
                + RANDBETWEEN ( 1, 100 ) / 1000
        )
    )
)

Thanks for your reply!.

 

Now it only sum one of the members which are tied.

Capture.PNG

 

 

But the behavior i expect is cardenas shoud be 11.511 + 515 and COMALCALCO should be 12.026 + 515. 

HI @chsardas

 

Instead of Running_Total try doing this for Ranking City

 

The idea is to differentiate between 2 similar Ranks by decimal points. You can hide the decimals for RANKING

 

Ranking City =
RANKX ( ALL ( Sales[City] ), [QTR Quantity],, DESC, SKIP )
    + RANDBETWEEN ( 1, 100 ) / 1000

Nice idea, now the ranking shows different values:Capture.PNG

 

 

But the running total keeps returning the same, it looks like the top n doesn't take care of the decimal. 😞

HI @chsardas

 

Sorry I went to sleep.

Could you try this please?

I hope it will work

 

 

Ranking City =
RANKX (
    ALL ( Sales[City] ),
    [QTR Quantity]
        + RANDBETWEEN ( 1, 100 ) / 1000,
    ,
    DESC,
    SKIP
)

Hi!! Now the ranking works better but the running total is really weird:

Capture.PNG

 

 

 

Could you share your file via one drive or googledrive?

I've sent you a PM. Smiley Happy

Finnally i´ve got the solution.

 

I´ve changed the approach of the formula.

 

Used this guide (it´s in spanish)

 

https://www.pbiusergroup.com/blogs/victor-velarde/2017/07/07/como-realizar-un-diagrama-8020-o-de-dis...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.