Select Top 5 based on multiple criteria

nikhil0311

Board Regular
Joined
May 3, 2013
Messages
200
Office Version
  1. 2013
Platform
  1. Windows
ABCDEFGHI
Criteria

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FF0000]#FF0000[/URL] , align: center"]ID[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FF0000]#FF0000[/URL] , align: center"]Stage[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FF0000]#FF0000[/URL] , align: center"]Country[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FF0000]#FF0000[/URL] , align: center"]$ Revenue[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]Bid[/TD]
[TD="align: center"]India[/TD]
[TD="align: center"]$7[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]3[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]Bid[/TD]
[TD="align: center"]India[/TD]
[TD="align: center"]$5[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]4[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]Mandate[/TD]
[TD="align: center"]China[/TD]
[TD="align: center"]$4[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FF0000]#FF0000[/URL] , align: center"]Stage[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4F6228]#4F6228[/URL] , align: center"]Bid[/TD]
[TD="align: right"][/TD]

[TD="align: center"]5[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]Bid[/TD]
[TD="align: center"]India[/TD]
[TD="align: center"]$6[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FF0000]#FF0000[/URL] , align: center"]Country[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=4F6228]#4F6228[/URL] , align: center"]India[/TD]
[TD="align: right"][/TD]

[TD="align: center"]6[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"]Opp[/TD]
[TD="align: center"]HK[/TD]
[TD="align: center"]$2[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]7[/TD]
[TD="align: center"]76[/TD]
[TD="align: center"]Bid[/TD]
[TD="align: center"]India[/TD]
[TD="align: center"]$4[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FF0000]#FF0000[/URL] , align: center"]Top 5[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FF0000]#FF0000[/URL] , align: center"]ID[/TD]
[TD="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=FF0000]#FF0000[/URL] , align: center"]$ Revenue[/TD]

[TD="align: center"]8[/TD]
[TD="align: center"]89[/TD]
[TD="align: center"]Mandate[/TD]
[TD="align: center"]China[/TD]
[TD="align: center"]$5[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]12[/TD]

[TD="align: center"]9[/TD]
[TD="align: center"]54[/TD]
[TD="align: center"]opp[/TD]
[TD="align: center"]Aus/NZ[/TD]
[TD="align: center"]$6[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]33[/TD]
[TD="align: center"]10[/TD]

[TD="align: center"]10[/TD]
[TD="align: center"]33[/TD]
[TD="align: center"]Opp[/TD]
[TD="align: center"]Aus/NZ[/TD]
[TD="align: center"]$7[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]45[/TD]
[TD="align: center"]8[/TD]

[TD="align: center"]11[/TD]
[TD="align: center"]45[/TD]
[TD="align: center"]Bid[/TD]
[TD="align: center"]India[/TD]
[TD="align: center"]$8[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]6[/TD]

[TD="align: center"]12[/TD]
[TD="align: center"]43[/TD]
[TD="align: center"]Opp[/TD]
[TD="align: center"]Malaysia[/TD]
[TD="align: center"]$9[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: center"]5[/TD]
[TD="align: center"]76[/TD]
[TD="align: center"]4[/TD]

[TD="align: center"]13[/TD]
[TD="align: center"]33[/TD]
[TD="align: center"]Bid[/TD]
[TD="align: center"]India[/TD]
[TD="align: center"]$10[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

</tbody>
Sheet2




Hello Friends
I have a data from column A1:D13
based on column A i.e. ID AND column B i.e. stage AND column C i.e. Country
I want to sum Column D i.e. Revenue.

For instance if Id is 1 and Stage is Bid & Country is India then the revenue should be $12.
Now in Column G4:H5 I have criteria and based on this criteria i want Top 5 Revenues & ID's based on Revenue (largest to smallest)in Column H8:I13.
Let me know if this is possible or not?

Thanks in advance!!
 
Last edited:

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

Book1
ABCDEFGH
1IDStageCountry$ RevenueCriteria
21BidIndia7StageBid
31BidIndia5CountryIndia
42MandateChina4Top5
54BidIndia6Top 5 Value4
65OppHK2Top 5 Adjusted5
776BidIndia4
889MandateChina5ID$ Revenue
954oppAus/NZ6112
1033OppAus/NZ73310
1145BidIndia8458
1243OppMalaysia946
1333BidIndia10764
14
Sheet1


1. H4 houses the desired Top N value.

2. In H5 control+shift+enter, not just enter:

=LARGE(SUMIFS(D2:D13,B2:B13,H2,C2:C13,H3,A2:A13,IF(FREQUENCY(IF(1-(A2:A13=""),IF(B2:B13=H2,IF(C2:C13=H3,MATCH(A2:A13,A2:A13,0)))),ROW(A2:A13)-ROW(A2)+1),A2:A13)),MIN(H4,SUM(IF(FREQUENCY(IF(1-(A2:A13=""),IF(B2:B13=H2,IF(C2:C13=H3,MATCH(A2:A13,A2:A13,0)))),ROW(A2:A13)-ROW(A2)+1),1))))

This cell calculates the Nth conditional sum...

3. In H6 control+shift+enter, not just enter:

=IFERROR(SUM(IF(SUMIFS(D2:D13,B2:B13,H2,C2:C13,H3,A2:A13,IF(FREQUENCY(IF(1-(A2:A13=""),IF(B2:B13=H2,IF(C2:C13=H3,MATCH(A2:A13,A2:A13,0)))),ROW(A2:A13)-ROW(A2)+1),A2:A13))>=H5,1)),0)

This cell re-calculates the Top N value based on the available data and the ties of the Nth value if any.

4. In G9 control+shift+enter, not just enter, and copy down in order to list the Top ID's:

=IF($H9="","",INDEX($A$2:$A$13,SMALL(IF(SUMIFS($D$2:$D$13,$B$2:$B$13,$H$2,$C$2:$C$13,$H$3,$A$2:$A$13,IF(FREQUENCY(IF(1-($A$2:$A$13=""),IF($B$2:$B$13=$H$2,IF($C$2:$C$13=$H$3,MATCH($A$2:$A$13,$A$2:$A$13,0)))),ROW($A$2:$A$13)-ROW($A$2)+1),$A$2:$A$13))=$H9,ROW($A$2:$A$13)-ROW($A$2)+1),COUNTIFS($H$9:H9,H9))))

5. In H9 control+shift+enter, not just enter, and copy down in order to list the Top revenues:

=IF(ROWS($H$9:H9)>$H$6,"",LARGE(SUMIFS($D$2:$D$13,$B$2:$B$13,$H$2,$C$2:$C$13,$H$3,$A$2:$A$13,IF(FREQUENCY(IF(1-($A$2:$A$13=""),IF($B$2:$B$13=$H$2,IF($C$2:$C$13=$H$3,MATCH($A$2:$A$13,$A$2:$A$13,0)))),ROW($A$2:$A$13)-ROW($A$2)+1),$A$2:$A$13)),ROWS($H$9:H9)))
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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