Rank based on two criteria without ties

mii0502

New Member
Joined
Sep 9, 2022
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hello guys :giggle: Hope you have a nice day!

I need to rank projects in descending order based on:
1. Their scores
2. If their scores are a tie, compare their YTD scores - the higher score the better rank
3. If their YTD scores are also a tie, just randomly assign their ranks
*I want the ranks to be shown as Rank/Total (Ex: 16/30)

I'm stucking at step 3. Now they have the same rank if their scores and YTD scores are tie.
For step 1&2, I use the formula: =RANK([@Score],[Score],0)+SUMPRODUCT(--([Score]=D4),--([YTD]>C4))&"/30"
Please refer to the sample as below.

Thanks so much for your help!

Sample.xlsx
BCDE
3ProjectYTDScoreRank
4CV85.1878/30
5Green86.38414/30
6Happy80.98020/30
7Happy Premier86.6877/30
8HP83.48316/30
9HP Premier88.8869/30
10MD89.5922/30
11NK77.67330/30
12NP82.87922/30
13PV77.07826/30
14H2487.1876/30
15P578.68217/30
16SSR83.07628/30
17MD377.07826/30
18MD480.98020/30
19R1-280.98513/30
20R377.97825/30
21Cross74.57924/30
22Star85.18415/30
23S4386.28610/30
24M586.08611/30
25M790.5913/30
26M690.6931/30
27H6384.18612/30
28Amelie88.6914/30
29Chateau83.4905/30
30H2283.68118/30
31HCN78.07629/30
32R77.07923/30
33S79.88119/30
Ranking (2)
Cell Formulas
RangeFormula
E4:E33E4=RANK([@Score],[Score],0)+SUMPRODUCT(--([Score]=D4),--([YTD]>C4))&"/30"
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
I would consider something like the approach shown below, which will require some explanation. You have 3 ranking/tie-breaking criteria and 30 projects. I would create a composite score based on mapping each ranking/tie-breaking criteria to powers of 10. Since you have 30 projects, you need at least 10^2 (100) positions to accommodate each ranking/tie-breaking criteria. These scoring positions need to be separated sufficiently so that the highest priority criterion (based on Score) cannot be affected by the 2nd highest priority criterion (based on YTD). Similarly, the YTD rankings cannot be affected by the randomization in the 3rd step, should it be necessary. So I propose a ranking composite score that looks like this:
Excel Formula:
=10000*RANK([@Score],[Score],0)+100*RANK([@YTD],[YTD],0)+RAND()
This formula ranks primarily by Score and weights the ranking by 10^4. Next a smaller component of the composite score is added, consisting of the rank by YTD weighted by 10^2. Because each of these constituent rankings range from 1..30, the weighting factors ensure that YTD rankings can not override the Score rankings. Then a small random number between 0..1 is weighted by 10^0 (i.e., 1) and added to the composite score. Finally, since all of the tie-breaking elements are accounted for in these composite scores, the composite scores are ranked from 1 to 30 using:
Excel Formula:
=RANK([@[Composite Score]],[Composite Score],1)
MrExcel_20220909b.xlsx
BCDENO
3ProjectYTDScoreRankComposite ScoreFinal Ranking
4CV85.13878/3061100.678/30
5Green86.258414/30140800.2514/30
6Happy80.888020/30201900.6921/30
7Happy Premier86.63877/3060700.247/30
8HP83.388316/30161500.2316/30
9HP Premier88.75869/3090400.129/30
10MD89.5922/3020300.042/30
11NK77.637330/30302600.8630/30
12NP82.757922/30221800.7022/30
13PV777826/30252700.3126/30
14H2487.13876/3060600.746/30
15P578.638217/30172300.3917/30
16SSR837628/30281700.9228/30
17MD3777826/30252700.4827/30
18MD480.888020/30201900.6020/30
19R1-280.888513/30131900.6913/30
20R377.887825/30252500.6825/30
21Cross74.57924/30223000.6624/30
22Star85.138415/30141100.8115/30
23S4386.28610/3090900.0810/30
24M5868611/3091000.6111/30
25M790.5913/3030200.873/30
26M690.63931/3010100.221/30
27H6384.138612/3091300.9012/30
28Amelie88.6914/3030500.794/30
29Chateau83.38905/3051500.435/30
30H2283.638118/30181400.7618/30
31HCN787629/30282400.5729/30
32R777923/30222700.7723/30
33S79.758119/30182200.4219/30
Sheet3
Cell Formulas
RangeFormula
E4:E33E4=RANK([@Score],[Score],0)+SUMPRODUCT(--([Score]=D4),--([YTD]>C4))&"/30"
N4:N33N4=10000*RANK([@Score],[Score],0)+100*RANK([@YTD],[YTD],0)+RAND()
O4:O33O4=RANK([@[Composite Score]],[Composite Score],1)&"/30"
 
Upvote 0
3. If their YTD scores are also a tie, just randomly assign their ranks
Would it be acceptable instead to make that final split based simply on which order the projects are in the table? If so you could try the following.
(I have also taken out the hard-coded 30 denominator in case table rows are added/deleted.)

mii0502.xlsm
BCDE
3ProjectYTDScoreRank
4CV85.125878/30
5Green86.258414/30
6Happy80.8758020/30
7Happy Premier86.625877/30
8HP83.3758316/30
9HP Premier88.75869/30
10MD89.5922/30
11NK77.6257330/30
12NP82.757922/30
13PV777826/30
14H2487.125876/30
15P578.6258217/30
16SSR837628/30
17MD3777827/30
18MD480.8758021/30
19R1-280.8758513/30
20R377.8757825/30
21Cross74.57924/30
22Star85.1258415/30
23S4386.28610/30
24M5868611/30
25M790.5913/30
26M690.625931/30
27H6384.1258612/30
28Amelie88.6914/30
29Chateau83.375905/30
30H2283.6258118/30
31HCN787629/30
32R777923/30
33S79.758119/30
Sheet1 (2)
Cell Formulas
RangeFormula
E4:E33E4=RANK([@Score],[Score],0)+SUMPRODUCT(--([Score]=D4),--([YTD]>C4))+COUNTIFS(INDEX([Score],1):[@Score],[@Score],INDEX([YTD],1):[@YTD],[@YTD])-1&"/"&COUNT([Score])
 
Upvote 0
Solution
I like Peter's suggestion for the 3rd level tie-breaker. Using the list position is less volatile than using RAND()...which is what I used above to add some jitter to the composite scores. With RAND(), you will find the ranks changing as the spreadsheet recalculates due to unrelated edits elsewhere. The list position is probably not random--as you might sort it according to various criteria--but it is reasonably stable. I also like the idea to generalize the formula to avoid a hardwired "30" denominator. Based on the approach I described for weighting, my formula would be limited to 99 projects before the potential exists for the 2nd tie-breaker to take priority over the 1st. Should that ever occur, one remedy is to change the weighting factors to 10^6 and 10^3. A variant of my original approach that adopts these ideas from Peter is here:
MrExcel_20220909b.xlsx
BCDEN
3ProjectYTDScoreRankComposite Score
4CV85.13878/3061100.03
5Green86.258414/30140800.07
6Happy80.888020/30201900.10
7Happy Premier86.63877/3060700.13
8HP83.388316/30161500.17
9HP Premier88.75869/3090400.20
10MD89.5922/3020300.23
11NK77.637330/30302600.27
12NP82.757922/30221800.30
13PV777826/30252700.33
14H2487.13876/3060600.37
15P578.638217/30172300.40
16SSR837628/30281700.43
17MD3777827/30252700.47
18MD480.888021/30201900.50
19R1-280.888513/30131900.53
20R377.887825/30252500.57
21Cross74.57924/30223000.60
22Star85.138415/30141100.63
23S4386.28610/3090900.67
24M5868611/3091000.70
25M790.5913/3030200.73
26M690.63931/3010100.77
27H6384.138612/3091300.80
28Amelie88.6914/3030500.83
29Chateau83.38905/3051500.87
30H2283.638118/30181400.90
31HCN787629/30282400.93
32R777923/30222700.97
33S79.758119/30182201.00
Sheet3 (2)
Cell Formulas
RangeFormula
E4:E33E4=RANK([@[Composite Score]],[Composite Score],1)&"/"&COUNT([Score])
N4:N33N4=10000*RANK([@Score],[Score],0)+100*RANK([@YTD],[YTD],0)+ROWS(N$4:N4)/COUNT([Score])
 
Upvote 0
KRice: Thank you so much for your detailed explanation, I'll definitely look more into the math behind it. 🤗
Peter_SSs: Thanks for your solution, it worked just like I wanted. 👏
 
Upvote 0
Peter_SSs: Thanks for your solution, it worked just like I wanted.
You're welcome. Thanks for the confirmation. :)

.. using RAND()...
Just one other comment on the use of RAND for splitting the ties. It would be extremely unlikely, but theoretically possible that two or more of such RAND calculations could produce the same result so it does not give an absolute guarantee that ties would be split.
 
Upvote 0
It would be extremely unlikely, but theoretically possible
I chuckled when I read that, Peter. True, but that is more of a theoretical concern than a practical one. I suppose Excel's numeric precision limitations also contribute because a continuous random variable becomes discretized due to those precision limits. I'm mostly opposed to the use of RAND() due to its volatility. A user of the worksheet might be in the process of using the rankings for something only to discover that the displayed ranks no longer match the earlier results. That's why some other scheme for the 3rd tie-breaker makes sense. For as often as a 3rd tie-breaker might be needed, one could rely on the good old-fashioned coin flip and simply resolve the tie manually. For an automated solution, list position certainly leads to a resolution, although one that still might be challenged by someone arguing that the wrong sort order was used.:rolleyes: I don't know if the Score and YTD values are rounded to some absolute precision, or how those values are determined, but a 3rd tie-breaker could consider examining those values with higher precision, the distribution of values comprising those scores, or something else related to them.

KRice: Thank you so much for your detailed explanation, I'll definitely look more into the math behind it.
You're welcome...we're happy to help. As for the math, my approach still relies on determining the rank for each project for each of the first two tie-breakers. So for tie-breaker #1, we'll have ranks 1-30. These are mapped to large numbers by multiplying by 10^4, so the ranks assume values of 10000, 20000, 30000, 40000,..., 300000. For tie-breaker #2, we'll again have ranks 1-30, but these get mapped to smaller numbers by multiplying by 10^2, so the ranks assume values of 100, 200, 300, 400,..., 3000. Note that even the largest value here (3000) does not exceed the interval between adjacent scores for tie-breaker #1 (those intervals are 10000), so we can safely add the mapped scores without changing the rankings. The 3rd tiebreaker then uses some arbitrary scheme to add a small amount to each sum. And if we're using list position, I've divided the list position by the total number of projects (n), so these values are between 1/n and 1...still such a small amount that the 3rd tie-breaker does not interfere with the rankings established by the 1st and 2nd tie-breakers. Looking at this now, the division by n really isn't necessary...we could just as well add the list position 1, 2, 3,..., 30 to the score and that too would work fine, as the largest value (30) is not large enough to exceed the interval of 100 in the 2nd tie-breaker scoring. Knowing how the composite scores are created, one can decipher the ranks for each tie-breaker component. Taking Project MD with a composite score of 20300.23, we can tell that:
  • it ranks 2 for tie-breaker 1 (ignore the 4 digits to the left of the decimal point and see what remains to the left),
  • it ranks 3 for tie-breaker 2 (ignore the two digits to the left of the decimal point and look at the next two digits to the left "03"),
  • and for the 3rd tie-breaker, we look at the 1's place and the decimal component (0.23), and from this, we can see that this project is in the 7th list position (0.23*30=6.9, note the 0.23 is display-rounded to a precision of 0.01).
 
Upvote 0
Can the end value to rank not be score + (ytd/100)
so for cv it’s 87.8513 this would give a clear ranking apart from a dead heat which resolve as original list order
then rank by what ever method you prefer rank or sumproduct
 
Upvote 0
Can the end value to rank not be score + (ytd/100)
Interesting idea...yes, that would work too--a variation of the approach I described except the tie-breaking tiers aren't ranked initially. Instead, their original scores are used directly and mapped to certain decimal locations. The only potential issue is incorporating the 3rd tie breaker, which would need to be an even smaller decimal value that would not conflict with the 2nd tie-breaker score. I've made a comparison of these two mapping ideas below. In the "K" version, I've revised the 3rd tie-breaker to occupy the rightmost 2 digits (10's and 1's place values) so than the ranks/list position can be read directly from the composite score. In the "J" version, I've divided the list position by 10^8 to shift it far to the right of the decimal. The only difference in final rankings is due to the 3rd tie-breaker where the "K" version effectively gives priority to the uppermost of a tied pair while the "J" version gives priority to the lowermost (either option could be justified).
MrExcel_20220909b.xlsx
BCDEOPQR
3ProjectYTDScoreRankK_CompScoreK_RankJ_CompScoreJ_Rank
4CV85.125878/3061101887.858
5Green86.258414/301408021484.8614
6Happy80.8758020/302019032080.8121
7Happy Premier86.625877/3060704787.877
8HP83.3758316/301615051683.8316
9HP Premier88.75869/3090406986.899
10MD89.5922/3020307292.902
11NK77.6257330/303026083073.7830
12NP82.757922/302218092279.8322
13PV777826/302527102678.7727
14H2487.125876/3060611687.876
15P578.6258217/301723121782.7917
16SSR837628/302817132876.8328
17MD3777827/302527142778.7726
18MD480.8758021/302019152180.8120
19R1-280.8758513/301319161385.8113
20R377.8757825/302525172578.7825
21Cross74.57924/302230182479.7524
22Star85.1258415/301411191584.8515
23S4386.28610/30909201086.8610
24M5868611/30910211186.8611
25M790.5913/3030222391.913
26M690.625931/3010123193.911
27H6384.1258612/30913241286.8412
28Amelie88.6914/3030525491.894
29Chateau83.375905/3051526590.835
30H2283.6258118/301814271881.8418
31HCN787629/302824282976.7829
32R777923/302227292379.7723
33S79.758119/301822301981.8019
Sheet3 (2)
Cell Formulas
RangeFormula
E4:E33E4=RANK([@[Composite Score]],[Composite Score],1)&"/"&COUNT([Score])
O4:O33O4=10^4*RANK([@Score],[Score],0)+10^2*RANK([@YTD],[YTD],0)+ROWS(N$4:N4)
P4:P33P4=RANK([@[K_CompScore]],[K_CompScore],1)
Q4:Q33Q4=[@Score]+[@YTD]/100+ROWS(Q$4:Q4)/10^8
R4:R33R4=RANK([@[J_CompScore]],[J_CompScore],0)
 
Upvote 0
You can also use RANK and COUNTIF to give unique ranking but it will give precedence to original place in list
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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