RankX - To avoid ties - Rank over two calculate criteria

lager1001

Board Regular
Joined
May 17, 2019
Messages
88
I have my RankX formula working great but I do notice ties in some instances and want to avoid those. So I want to add to this rank order, another calculated criteria. Currently I am ranking Vendors by count of rows (count of transactions) but in some cases I get a tie. In order to break those ties I'd like to not only rank 1st by count of instances but additional by the sum of quantities shipped (separate column) by vendor for those counted rows. How can incorporate both calculations into one RankX formula?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
It's hard to imagine how your data is, but here I show you an example, I hope it helps you.

Dante Amor
ABCDEFG
1VENDORQTYVENDORTRANSACTIONSQTYRANK
2VENDOR21VENDOR2363
3VENDOR22VENDOR3372
4VENDOR23VENDOR42174
5VENDOR34VENDOR5165
6VENDOR32VENDOR64541
7VENDOR31
8VENDOR415
9VENDOR42
10VENDOR56
11VENDOR612
12VENDOR613
13VENDOR614
14VENDOR615
Hoja7
Cell Formulas
RangeFormula
E2:E6E2=COUNTIFS($A$2:$A$14,D2)
F2:F6F2=SUMIF($A$2:$A$14,D2,$B$2:$B$14)
G2:G6G2=COUNTIF($E$2:$E$6,">"&E2)+COUNTIFS($E$2:$E$6,E2,$F$2:$F$6,">"&F2)+1
 
Upvote 0
Can you share your current DAX formula and some exemplary data? Did you create RANKX as a new measure or as a new column?
 
Upvote 0
I created it as a new calculate column. My current DAX formula is as follows and works perfectly but again I get ties for any vendors with the same amount of rows (transactions) and I need to break this tie:

IF(AND(Data[Vendor Number]<>BLANK(),Data[Filter_12_Weeks]="within prev 12 weeks"),RANKX (ALLSELECTED ( Data[Vendor Number]),CALCULATE (COUNTROWS ( Data),ALLEXCEPT ( Data,Data[Vendor Number], Data[Filter_12_Weeks])),,DESC,Dense))

What I need is to somehow incorporate a sum of the [QTY] column for each [Vendor Number]. It should rank first by the count of rows per [Vendor Number] and per each[Filter_12_Weeks] as it does in the above formula, but secondly by the highest sum of [QTY] per each [Vendor Number] and [Filter_12_Weeks]. This should break ties and give me a true ranking. Make sense?
 
Upvote 0
Thanks for explaining.

Here's one idea for you to try - how about combining Count of rows with Quantity, and then ranking the whole dataset by this combined number?
What I mean is:
1585259224625.png


In DAX it should look somewhat like that:
Rich (BB code):
cRank = 
    var CR = CALCULATE(COUNTROWS(DataV), ALLEXCEPT(DataV, DataV[Vendor Number], DataV[Filter_12_Weeks]))
    var Q = CALCULATE(SUM(DataV[Quantities]))
    var NewMetric = FORMAT(CR & "," & Q, "0.00")
return
    NewMetric

You can then use this NewMetric in your RANKX formula, instead of CALCULATE (COUNTROWS ( Data),ALLEXCEPT ( Data,Data[Vendor Number], Data[Filter_12_Weeks])).
Let me know if this worked for you.
 
Upvote 0
Got this in. But it doesn't seem to be ranking correctly. Still experimenting.
 
Last edited:
Upvote 0
Yep, not doing what I need it to do. But I like the idea. I'm considering now to do three rankings: Rank 1 by Count, Rank 2 by QTY, Combine the two rankings per the metric, then rank the metric. Will follow up with my results.
 
Upvote 0
Fingers crossed! I know it's not really a straightforward method but I'm hoping this sneaky idea will work for you :)
 
Upvote 0
I couldn't get this to work as I wanted it to. I know it has to be possible but I haven't discovered the proper syntax. I ended up doing it in Power Query as a double group by table and added an index column for my rank and ran with that. It works. Not what I really wanted but it works until I can figure out the power pivot DAX way of doing it.
 
Upvote 0

Forum statistics

Threads
1,214,659
Messages
6,120,786
Members
448,993
Latest member
Seri

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top