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

Regards
Zubair

Please try my custom visuals

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

Regards
Zubair

Please try my custom visuals

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
)

Regards
Zubair

Please try my custom visuals

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?

Regards
Zubair

Please try my custom visuals

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
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.