Rank data with criteria

pto160

Active Member
Joined
Feb 1, 2009
Messages
365
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I would like to rank data based on sales in a division. The sales in the other divisions would not affect the rankings in for example the Central Division. Duplicates would be assigned the same rank. Is there any way to use a sum(if or small, large formula. I am trying to avoid the rank formula because it does not work with closed workbooks.

<title>Excel Jeanie HTML</title>Sheet2

<table style="background-color: rgb(255, 255, 255); padding-left: 2pt; padding-right: 2pt; font-family: Arial,Arial; font-size: 10pt;" border="1" cellpadding="0" cellspacing="0"> <colgroup> <col style="width: 30px; font-weight: bold;"> <col style="width: 94px;"> <col style="width: 64px;"> <col style="width: 64px;"> <col style="width: 64px;"></colgroup> <tbody> <tr style="text-align: center; background-color: rgb(202, 202, 202); font-size: 8pt; font-weight: bold;"> <td> </td> <td>A</td> <td>B</td> <td>C</td> <td>D</td></tr> <tr style="height: 17px;"> <td style="text-align: center; background-color: rgb(202, 202, 202); font-size: 8pt;">13</td> <td> </td> <td> </td> <td> </td> <td>End Rank</td></tr> <tr style="height: 17px;"> <td style="text-align: center; background-color: rgb(202, 202, 202); font-size: 8pt;">14</td> <td>Salesperson A</td> <td style="text-align: right;">10000</td> <td>East</td> <td style="text-align: right;">2</td></tr> <tr style="height: 17px;"> <td style="text-align: center; background-color: rgb(202, 202, 202); font-size: 8pt;">15</td> <td>Salesperson B</td> <td style="text-align: right;">20000</td> <td>Central</td> <td style="text-align: right;">3</td></tr> <tr style="height: 17px;"> <td style="text-align: center; background-color: rgb(202, 202, 202); font-size: 8pt;">16</td> <td>Salesperson C</td> <td style="text-align: right;">30000</td> <td>Central</td> <td style="text-align: right;">2</td></tr> <tr style="height: 17px;"> <td style="text-align: center; background-color: rgb(202, 202, 202); font-size: 8pt;">17</td> <td>Salesperson D</td> <td style="text-align: right;">40000</td> <td>East</td> <td style="text-align: right;">1</td></tr> <tr style="height: 17px;"> <td style="text-align: center; background-color: rgb(202, 202, 202); font-size: 8pt;">18</td> <td>Salesperson E</td> <td style="text-align: right;">40000</td> <td>East</td> <td style="text-align: right;">1</td></tr> <tr style="height: 17px;"> <td style="text-align: center; background-color: rgb(202, 202, 202); font-size: 8pt;">19</td> <td>Salesperson F</td> <td style="text-align: right;">50000</td> <td>West</td> <td style="text-align: right;">3</td></tr> <tr style="height: 17px;"> <td style="text-align: center; background-color: rgb(202, 202, 202); font-size: 8pt;">20</td> <td>Salesperson G</td> <td style="text-align: right;">60000</td> <td>West</td> <td style="text-align: right;">2</td></tr> <tr style="height: 17px;"> <td style="text-align: center; background-color: rgb(202, 202, 202); font-size: 8pt;">21</td> <td>Salesperson H</td> <td style="text-align: right;">70000</td> <td>Central</td> <td style="text-align: right;">1</td></tr> <tr style="height: 17px;"> <td style="text-align: center; background-color: rgb(202, 202, 202); font-size: 8pt;">22</td> <td>Salesperson F</td> <td style="text-align: right;">80000</td> <td>West</td> <td style="text-align: right;">1</td></tr></tbody></table>

Excel tables to the web >> Excel Jeanie HTML 4
 

Some videos you may like

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

sijpie

Well-known Member
Joined
Nov 1, 2008
Messages
3,734
I use a array formula (Ctrl-ShiftEnter) to do such a thing

{=MAX(IF($C$4:$C$487=G1,$B$4:$B$487))}
where G1 contains the name I want to sort on, in your case 'Central', etc.


to get the second and third largest use LARGE(...,2) or LARGE(....,3)
 

barry houdini

MrExcel MVP
Joined
Mar 23, 2005
Messages
20,825
In normal ranking for the East Division the top 2 are both 40000 so they'd be assigned 1, but then row 14 would be assigned 3 (not 2 as per your example). Is that deliberate, do you want to rank "without gaps"?

"Normal" ranking would be given by this formula in D14 copied down

=SUMPRODUCT((C$14:C$22=C14)*(B$14:B$22>B14))+1

or for the "without gaps" option you could use this "array formula"

=SUM(IF(FREQUENCY(IF(B$14:B$22>B14,IF(C$14:C$22=C14,MATCH(B$14:B$22,B$14:B$22,0))),ROW(B$14:B$22)-ROW(B$14)+1),1))+1

confirmed with CTRL+SHIFT+ENTER
 

pto160

Active Member
Joined
Feb 1, 2009
Messages
365
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Yes, more than likely, I would be ranking with no gaps. I tried out the formulas and they work great. I edited the sumproduct that gave me the same result.

Does the sumproduct work with closed workbooks?
Why would I use the sumproduct you gave me instead of
=SUM((C$14:C$22=C14)*(B$14:B$22>B14))+1?

I am just trying to decide when it is appropriate to use sumproduct.
The formulas are fantastic.
 

barry houdini

MrExcel MVP
Joined
Mar 23, 2005
Messages
20,825
You can use SUM instead of SUMPRODUCT in that first one if you want, it just means it needs to be array entered (SUMPRODUCT dosen't need that). Either one should work with a closed workbook
 

pto160

Active Member
Joined
Feb 1, 2009
Messages
365
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Thank you for the explanation. Once again, thanks for all your help.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,483
Messages
5,596,405
Members
414,064
Latest member
Duncthegreat

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
Top