Rank lowest to highest with similar values

Stuepef

Board Regular
Joined
Oct 23, 2017
Messages
128
Office Version
  1. 2021
Platform
  1. Windows
I have values in column A that vary in length and characters. I want to rank those values from lowest to highest, but i am running into duplicates even though the values are different. I have different formulas in columns C & D to dissect the information in different ways, but its not working how I want it to. I am looking for assistance to differentiate these values to accurately rank them from lowest to highest.

Workbook:
Code:
[TABLE="width: 668"]
<tbody>[TR]
[TD][/TD]
[TD]Formula 1[/TD]
[TD]Formula 2[/TD]
[TD]Rank on formula 1[/TD]
[TD]Rank on formula 2[/TD]
[/TR]
[TR]
[TD]Pontiac $500-$20[/TD]
[TD]500[/TD]
[TD]500-20[/TD]
[TD]1[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]Feet $500-$40[/TD]
[TD]500[/TD]
[TD]500-40[/TD]
[TD]1[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]USA Feet $2,000-100% Gt Plus[/TD]
[TD]2000[/TD]
[TD]2000-100[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]USA Feet $2,000-100%[/TD]
[TD]2000[/TD]
[TD]2000-100[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]Orange $3,000-70% Treat ACE Free[/TD]
[TD]3000[/TD]
[TD]3000-70[/TD]
[TD]3[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]USA Emboss. Orange $3,000-80%[/TD]
[TD]3000[/TD]
[TD]3000-80[/TD]
[TD]3[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]USA Emboss. Orange $4,000-100% Gt Plus[/TD]
[TD]4000[/TD]
[TD]4000-100[/TD]
[TD]4[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]USA Emboss. Orange $4,000-100%[/TD]
[TD]4000[/TD]
[TD]4000-100[/TD]
[TD]4[/TD]
[TD]4[/TD]
[/TR]
</tbody>[/TABLE]

Formula 1:
Code:
=IFERROR(INT(LEFT(REPLACE(SUBSTITUTE(A2,"-"," "),1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&1/17))-1,""),5)),INT(LEFT(REPLACE(SUBSTITUTE(A2,"-"," "),1,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&1/17))-1,""),4)))

Formula 2:
Code:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(MID(A2,MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789")),FIND(" ",A2&" ",MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789")))-MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))),"$",""),"%",""),",","")

Rank formula for column C (this one is the closest in accuracy, except when the value is 3 digits or the exact same):
Code:
=IF(C3="","",SUMPRODUCT(($C$2:$C$9< C3)/COUNTIF($C$2:$C$9,$C$2:$C$9))+1)

Desired Result:
Code:
[TABLE="width: 326"]
<tbody>[TR]
[TD][/TD]
[TD]Rank[/TD]
[/TR]
[TR]
[TD]Pontiac $500-$20[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]Feet $500-$40[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]USA Feet $2,000-100%[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]USA Feet $2,000-100% Gt Plus[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]Orange $3,000-70% Treat ACE Free[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]USA Emboss. Orange $3,000-80%[/TD]
[TD]6[/TD]
[/TR]
[TR]
[TD]USA Emboss. Orange $4,000-100%[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]USA Emboss. Orange $4,000-100% Gt Plus[/TD]
[TD]8[/TD]
[/TR]
</tbody>[/TABLE]

Thank you!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
This task requires a different approach. What you're really after is a ranking with cascading conditions.

For example, sports leagues (and sales managers, among many others) use cascading rules to break ties. In a sports example, you could use the following rules: First by POINTS. Then by GAMES REMAINING. Then by WINS. Then by GOALS FOR. Then by GOAL DIFFERENTIAL. When trying to do this any other way, the problems mount with each successive rule. So I invented a method that works well enough. I create a new stat for each member (I call it GRADE) which I then use to rank the members of the group. GRADE is calculated by adding up all the various tiebreaker stats: but not just a straight summation (which wouldn’t work, obviously), rather a summation of each stat in declining order of magnitude. The magnitudes are computed so as to ensure that each one cannot get so large or small that it ‘ticks over’ the prior stat.

For your data, the first rule is by Criteria1, so I used your Formula1 to extract 4000 for USA Emboss. The second is Criteria2, so I used your Formula2 to extract the 100. The final is Criteria3, so I used a keyword (i.e., "plus") to report a 1 or 1 0 for whether or not it's a GT Plus. The result is 4000 + 100/(10^3) + 1/(10^(3+1)) for a Grade of 4000.1001. The other Grades are arrived at similarly and then they are ranked in ascending order.

Book1
ABCDEF
1orders of magnitude:31
2keyword:plus
3
4ProductCriteria1Criteria2Criteria3GradeRank (ascending)
5Pontiac $500-$20500200500.02001
6Feet $500-$40500400500.04002
7USA Feet $2,000-100% Gt Plus200010012000.10014
8USA Feet $2,000-100%200010002000.10003
9Orange $3,000-70% Treat ACE Free30007003000.07005
10USA Emboss. Orange $3,000-80%30008003000.08006
11USA Emboss. Orange $4,000-100% Gt Plus400010014000.10018
12USA Emboss. Orange $4,000-100%400010004000.10007
Sheet54
Cell Formulas
RangeFormula
D5=IF(ISNUMBER(SEARCH($D$2,A5)),1,0)
D1{=MAX(LEN(D5:D12))}
E5=B5+C5/(10^$C$1)+D5/(10^($C$1+$D$1))
F5=RANK.EQ(E5,$E$5:$E$12,1)
C1{=MAX(LEN(C5:C12))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
@DRSteele - thank you for the response. What happens if there are duplicates in the same list? For example, what if there are 2 or 3 Pontiac $500-$20? Would your logic still apply?

Code:
[TABLE="width: 437"]
<tbody>[TR]
[TD]Employee[/TD]
[TD]Products[/TD]
[TD]Rank[/TD]
[/TR]
[TR]
[TD]Employee A[/TD]
[TD]Feet $500-$40[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]Employee B[/TD]
[TD]Feet $500-$40[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]Employee C[/TD]
[TD]Pontiac $500-$20[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]Employee D[/TD]
[TD]USA Feet $2,000-100%[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]Employee E[/TD]
[TD]USA Feet $2,000-100%[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]Employee F[/TD]
[TD]Pontiac $500-$20[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]Employee G[/TD]
[TD]Pontiac $500-$20[/TD]
[TD]1[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Well yes: the function RANK.EQ will rank them as identical because they are identical. If they are identical and you have no more rules to discriminate amongst them, then they will get the same Grade and same Rank.
 
Upvote 0
DRSteele - I have other values that would need the same logic, but I am assuming I would just have to change the keywords. Here are the other values:
Code:
[TABLE="width: 248"]
<tbody>[TR]
[TD]LazyMaster Blue $300[/TD]
[/TR]
[TR]
[TD]LazyMaster Blue $500[/TD]
[/TR]
[TR]
[TD]LazyMaster Blue $750[/TD]
[/TR]
[TR]
[TD]LazyMaster Blue $1,000[/TD]
[/TR]
[TR]
[TD]LazyMaster Phone $2,300[/TD]
[/TR]
[TR]
[TD]LazyMaster Phone $2,700[/TD]
[/TR]
[TR]
[TD]LazyMaster USA Blue $1,500[/TD]
[/TR]
[TR]
[TD]LazyMaster USA Blue $2,200[/TD]
[/TR]
[TR]
[TD]LazyMaster USA Emboss. Yellow $2,700[/TD]
[/TR]
[TR]
[TD]LazyMaster USA Emboss. Yellow $3,600[/TD]
[/TR]
[TR]
[TD]LazyMaster USA Yellow $3,675[/TD]
[/TR]
[TR]
[TD]LazyMaster USA Emboss. Yellow $4,500[/TD]
[/TR]
[TR]
[TD]LazyMaster USA Emboss. Orange $5,200[/TD]
[/TR]
[TR]
[TD]LazyMaster USA Emboss. Orange $6,650[/TD]
[/TR]
[TR]
[TD]CoolValue Blue $1,000[/TD]
[/TR]
[TR]
[TD]CoolValue Yellow $2,300[/TD]
[/TR]
[TR]
[TD]CoolValue USA Yellow $3,600[/TD]
[/TR]
[TR]
[TD]CoolValue USA Orange $5,200[/TD]
[/TR]
[TR]
[TD]CoolValue USA Orange $6,650[/TD]
[/TR]
[TR]
[TD]Made Value Blue $1,000[/TD]
[/TR]
[TR]
[TD]Made Value Yellow $2,300[/TD]
[/TR]
[TR]
[TD]Made Value USA Yellow $3,600[/TD]
[/TR]
[TR]
[TD]Made Value USA Orange $5,200[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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