How to rank a combination of 2 or more columns?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,691
Office Version
  1. 365
Platform
  1. Windows
The first 2 columns in the table below are 5-star ratings, such as used on Amazon. I would like to rank them as a combined field sorted the way it is (Rating column Hi-Lo, # Reviews column Hi-Lo).

I discovered that the Rank functions only work with numbers, so the only thing I could think of was to create a helper column that generated a combined integer text string and then convert that to a number.

Is there a better way -- perhaps one that doesn't need the helper column?

Ranking.xlsx
CDEFG
5Rating# ReviewsRankHelperRank2
64.91149000000111
74.7123,62047001236202
84.718,60447000186043
94.71,75947000017594
104.638,08646000380865
114.621,06846000210686
124.617,78746000177877
134.67,79546000077958
144.67,54046000075409
154.67,489460000748910
164.64,864460000486411
174.64,487460000448712
184.63,778460000377813
194.63,246460000324614
204.62,883460000288315
214.62,399460000239916
224.6327460000032717
234.646460000004618
244.544,427450004442719
254.59,567450000956720
264.55,801450000580121
274.5456450000045622
284.48,509440000850923
294.143410000004324
Sheet1
Cell Formulas
RangeFormula
F6:F29F6=VALUE(TEXT([@Rating]*10,"0") & TEXT([@['# Reviews]],"00000000"))
G6:G29G6=RANK.EQ([@Helper],[Helper])
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Try this:

Book1
CDE
5Rating# ReviewsRank
64.9111
74.71236202
84.7186043
94.717594
104.6380865
114.6210686
124.6177877
134.677958
144.675409
154.6748910
164.6486411
174.6448712
184.6377813
194.6324614
204.6288315
214.6239916
224.632717
234.64618
244.54442719
254.5956720
264.5580121
274.545622
284.4850923
294.14324
Sheet1
Cell Formulas
RangeFormula
E6:E29E6=COUNTIFS($C$6:$C$29,">"&C6)+COUNTIFS($C$6:$C$29,C6,$D$6:$D$29,">"&D6)+1
 
Upvote 0
Solution
Or try:

Excel Formula:
=LET(a,C6:C29*10000000000+D6:D29/1000000000,b,SORT(a,,-1),MATCH(a,b,0))
 
Upvote 0
Try this:

Perfect. I'll have to study it a bit to figure out how it works. Any hits?

Here's the new table. I did modify your original code to use table syntax.

Ranking.xlsx
CDEFGHI
5Rating# ReviewsHelperRankPhuocPhuoc2Huish
64.7123,6204.7E+092221
74.544,4274.5E+091919192
84.638,0864.6E+095553
94.621,0684.6E+096664
104.718,6044.7E+093335
114.617,7874.6E+097776
124.59,5674.5E+092020207
134.48,5094.4E+092323238
144.67,7954.6E+098889
154.67,5404.6E+0999910
164.67,4894.6E+0910101011
174.55,8014.5E+0921212112
184.64,8644.6E+0911111113
194.64,4874.6E+0912121214
204.63,7784.6E+0913131315
214.63,2464.6E+0914141416
224.62,8834.6E+0915151517
234.62,3994.6E+0916161618
244.71,7594.7E+0944419
254.54564.5E+0922222220
264.63274.6E+0917171721
274.6464.6E+0918181822
284.1434.1E+0924242423
294.9114.9E+0911124
Sheet1
Cell Formulas
RangeFormula
E6:E29E6=VALUE(TEXT([@Rating]*10,"0") & TEXT([@['# Reviews]],"00000000"))
F6:F29F6=RANK.EQ([@Helper],[Helper])
G6:G29G6=COUNTIFS($C$6:$C$29,">"&C6)+COUNTIFS($C$6:$C$29,C6,$D$6:$D$29,">"&D6)+1
H6:H29H6=COUNTIFS([Rating],">"&[@Rating])+COUNTIFS([Rating],[@Rating],['# Reviews],">"&[@['# Reviews]])+1
I6:I29I6=ROWS($A$1:A1)
 
Upvote 0
I now have 3 quite different solutions as illustrated in the minisheet below. The task was to rank the first two columns, RatIngs & # Reviews, as if they were sorted on Ratings first, then on # Reviews.

Here's what the columns do:

The Helper and Helper Rank Columns were the only way I could think to make it work.

Then I asked here. Phuoc Rank1 is the solution Phuoc posted using cell syntax. Phuoc Rank2 is the version I modified to use table syntax.

I have been playing around with ChatGPT, so I asked it to solve this problem. After several rather obvious errors and misunderstandings, it came up with a solution using SumProduct with a combination of cell syntax for part of the expression and table syntax for the rest. I edited the expression so that ChatGPT Rank1 uses all cell syntax and ChatGPT Rank2 uses all table syntax.

The minisheet is sorted by the rank. In this view, it is sorted on the # Reviews column to show that the ranks all remain correct.

1723501162705.png


Ranking.xlsx
CDEFGHIJ
5Ratings# ReviewsHelperHelper RankPhuoc Rank1Phuoc Rank2ChatGPT Rank1ChatGPT Rank2
64.9114.9E+0911111
74.7123,6204.7E+0922222
84.718,6044.7E+0933333
94.71,7594.7E+0944444
104.638,0864.6E+0955555
114.621,0684.6E+0966666
124.617,7874.6E+0977777
134.67,7954.6E+0988888
144.67,5404.6E+0999999
154.67,4894.6E+091010101010
164.64,8644.6E+091111111111
174.64,4874.6E+091212121212
184.63,7784.6E+091313131313
194.63,2464.6E+091414141414
204.62,8834.6E+091515151515
214.62,3994.6E+091616161616
224.63274.6E+091717171717
234.6464.6E+091818181818
244.544,4274.5E+091919191919
254.59,5674.5E+092020202020
264.55,8014.5E+092121212121
274.54564.5E+092222222222
284.48,5094.4E+092323232323
294.1434.1E+092424242424
Rank on 2 Columns (01)
Cell Formulas
RangeFormula
E6:E29E6=VALUE(TEXT([@Ratings]*10,"0") & TEXT([@['# Reviews]],"00000000"))
F6:F29F6=RANK.EQ([@Helper],[Helper])
G6:G29G6=COUNTIFS($C$6:$C$29,">"&C6)+COUNTIFS($C$6:$C$29,C6,$D$6:$D$29,">"&D6)+1
H6:H29H6=COUNTIFS([Ratings],">"&[@Ratings])+COUNTIFS([Ratings],[@Ratings],['# Reviews],">"&[@['# Reviews]])+1
I6:I29I6=SUMPRODUCT(--((C6*1000000 + D6) < ($C$6:$C$29*1000000 + $D$6:$D$29))) + 1
J6:J29J6=SUMPRODUCT(--(([@Ratings]*1000000 + [@['# Reviews]]) < ([Ratings]*1000000 + ['# Reviews]))) + 1
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,081
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