RANK Formula with Criteria

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
1,494
Office Version
  1. 2016
Platform
  1. Windows
Hello Friends,

I need a Rank formula based on criteria

Here is a sample data (having Names in A2:A8 & Qty in D2:D8)

NAMES Qty
Peter25
John99
Mike36
Mike25
John48
Peter99
Peter2

<tbody>
</tbody>

Required names (rank wise) based on sum of Quantites in Column D

In this case answer should be

John (coz john has the maximum qty of 147)
Peter (then peter with a qty of 126)
Mike (then Mike with a qty of 61)

Any help would be appreciated.

Regards,

Humayun
 
Last edited:

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Maybe...


A
B
C
D
E
F
1
NAMES​
Qty​
Result​
2
Peter​
25​
John​
3
John​
99​
Peter​
4
Mike​
36​
Mike​
5
Mike​
25​
6
John​
48​
7
Peter​
99​
8
Peter​
2​
9

Array formula in F2 copied down
=IFERROR(INDEX(A$2:A$8,MATCH(LARGE(IF(ISNA(MATCH(A$2:A$8,F$1:F1,0)),SUMIF(A$2:A$8,A$2:A$8,D$2:D$8)),1),IF(ISNA(MATCH(A$2:A$8,F$1:F1,0)),SUMIF(A$2:A$8,A$2:A$8,D$2:D$8)),0)),"")
confirmed with Ctrl+Shift+Enter, not just Enter

Hope this helps

M.
 
Upvote 0
Hi Marcelo,

Formula you provided is working Perfect.

Thanks a lot

Humayun
 
Upvote 0
simply make pivort table sum qty and then sort by largest to smallest
 
Upvote 0
Hi aqeel,

Sorry i am not at all familiar with Pivot table
 
Upvote 0
Hi marcelo,

I Just noticed that the formula is taking too long to calculate...
The source data contains 1000 rows...

And also the source data file has to be open for the formula to give results.

Is there any solution to it ??
 
Upvote 0
I have given two solutions.Tested for Data for row 3 to row 1682.
1. With helper column C, very very fast.

In C3 then copied down till data in A column.

Code:
=IF((ROW()-ROW($A$2))=MATCH(A3,$A$3:$A3,0),SUMIF($A$3:$A$1682,$A3,$B$3:$B$1682),"")

For name list in E2 then copied down till blank cell is seen.

Code:
=IFERROR(INDEX($A$3:$A$1682,MATCH(LARGE($C$3:$C$1682,ROWS($E$2:$E2)),$C$3:$C$1682,0)),"")

2. Without helper column, takes more time.Approx 1 sec for each cell.

In G3 then copied down till blank cell is seen.

Code:
=IFERROR(INDEX($A$3:$A$1682,SMALL(IF(SUMIF($A$3:$A$1682,$A$3:$A$1682,$B$3:$B$1682)*(COUNTIF($G$2:$G2,$A$3:$A$1682)=0)=LARGE(IF(COUNTIF($G$2:$G2,$A$3:$A$1682)=0,SUMIF($A$3:$A$1682,$A$3:$A$1682,$B$3:$B$1682),""),1),ROW($A$3:$A$1682),""),1)-ROW($G$3)+1),"")
 
Upvote 0
Hi kvsrinivasamurthy ,

I tried the second solution one without the helper column...
It is working but its repeating some text when the unique text are over...

For example
If the date in rows 3 to 1682 contains text but with not more then 11 unique text
then the formula result is showing all the unique values till row 11 (that's fine) but in row 12 its repeating some text from the source date i.e. rows 3 to 1682..


EDIT POST..

The first solution works fine

 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,007
Members
448,935
Latest member
ijat

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