filter Top 5 by 2 criterions

Omer_K

Board Regular
Joined
Apr 9, 2017
Messages
124
Office Version
  1. 365
Dear All,
I have a database divided by countries and letters,
(Each letter has a separate column),
I also have a data validaion list in cell J3 with all letters (from letter A to letter F),
And another cell data validaion list in cell J6 that also has all the letters (from letter A to letter F),
I would like to know how I can use by functions (not 365 functions like filter) to list all countries so that if I select a letter in cell J3 the list will show me all the countries with the highest score (eg 10 countries) in that letter and once I select another letter in cell J6 the list will narrow For the 5 countries on the existing list with the highest score in the second list (J6),
I hope i was clear...

חוברת2
BCDEFGHIJ
1ABCDEF
21.254.651.733.6846.47
34.56.265.14.321.231.57First ChooseB
43.65.31.076.213.861.01
56.752.381.424.016.075.25
65.873.172.896.642.921.47Second Choose
75.281.641.483.873.441.73
84.822.732.854.474.211.3
96.225.181.061.893.994.38
105.721.85.445.795.64.52
114.414.876.65.913.086.9
124.233.344.655.924.425.08
135.876.686.424.311.916.99
144.636.513.734.296.225.29
155.352.282.745.624.066.16
163.534.412.496.615.524.26
173.682.854.886.115.511.21
183.992.814.63.482.591.62
192.436.663.033.633.421.6
203.646.96.915.216.623.08
215.512.095.94.632.555.2
225.083.014.385.492.243
236.932.974.55.812.625.43
244.512.64.064.025.641.61
251.066.15.466.774.485.03
261.686.536.911.34.312.33
272.244.633.35.315.334.12
286.645.493.274.451.384.76
294.693.762.653.044.786.64
304.745.744.042.481.891.54
311.014.163.585.632.614.81
323.962.144.065.012.563.86
333.415.063.462.171.443.99
346.993.593.974.234.793.47
355.045.491.71.44.241.59
362.822.186.462.761.873.2
Data
Cells with Data Validation
CellAllowCriteria
J3,J6List=$B$1:$G$1



Thank you,
 
Also, I should point out that selecting B and E results in a 3 way tie for 5th place, does that mean that 7 results should be shown instead of 5?

If only 5, how would you decide which of the 3 tied states is the correct result?

Below is a slightly modified approach to my last reply which shows the top 5 sorted as needed, along with any ties for last place up to a maximum of 10 rows.

The yellow helper section could be hidden by using a white font with no fill colour, you just need to remember where it is so that you don't delete it in error.
Sample Data.xlsm
ABCDEFGHIJKLMNO
1StateABCDEF
2Alabama2.671.672.331.673.672
3Alaska23.673.6731.673.67First ChooseA
4Arizona2.673322.332.33
5Arkansas222.331.3333
6California1.672.671.67333Second ChooseE
7Colorado1.671.3333.672.332
8Connecticut2.6721.331.3332StateABCDEF
9Delaware2.333.6733.672.333.67Nevada3.673.671.672.673.673
10Florida2.3322.67231.33North Dakota3.671.6722.673.673.67
11Georgia1.332222.333Iowa3332.333.672.67
12Hawaii22.671.33232.33Idaho33.67322.673.67
13Idaho33.67322.673.67Massachusetts[E]3231.332.332
14Illinois2.331.332.331.332.672New Mexico332.331.672.331.67
15Indiana2.332.333.671.331.671.67       
16Iowa3332.333.672.67       
17Kansas331.672.331.332       
18Kentucky[E]333.672.671.331.67       
19Louisiana2.671.331.331.332.332.33
20Maine1.6731.6731.332.33
21Maryland1.673.672.3321.673.67Top 101st2ndrank
22Massachusetts[E]3231.332.332Nevada3.673.671
23Michigan23.672.331.673.672.67North Dakota3.673.672
24Minnesota1.332.672.332.673.672.33Idaho32.674
25Mississippi2.331.671.673.6733Iowa33.673
26Missouri2.331.673.6722.333.67Kansas31.33 
27Montana21.67231.672.67Kentucky[E]31.33 
28Nebraska2.672.672.671.3323Massachusetts[E]32.335
29Nevada3.673.671.672.673.673New Mexico32.336
30New Hampshire1.333.6731.671.673    
31New Jersey1.331.331.672.671.672    
32New Mexico332.331.672.331.67
33New York1.672.332.67233.67
34North Carolina2.33232.673.673
35North Dakota3.671.6722.673.673.67
36Ohio2.6732.333.671.673
Sheet13
Cell Formulas
RangeFormula
I9:I18I9=IFERROR(INDEX($I$22:$I$31,MATCH(SMALL($L$22:$L$31,ROWS(I$9:I9)),$L$22:$L$31,0)),"")
J9:O18J9=IF($I9="","",INDEX($B$2:$G$36,MATCH($I9,$A$2:$A$36,0),MATCH(J$8,$B$1:$G$1,0)))
I22:I31I22=IF(J22="","",INDEX($A:$A,AGGREGATE(15,6,ROW($A$2:$A$36)/(INDEX($B$2:$G$36,0,MATCH($J$3,$B$1:$G$1,0))=J22),COUNTIF(J$22:J22,J22))))
J22:J31J22=IF(ROWS(J$22:J22)>COUNTIF(INDEX($B$2:$G$36,0,MATCH($J$3,$B$1:$G$1,0)),">="&LARGE(INDEX($B$2:$G$36,0,MATCH($J$3,$B$1:$G$1,0)),5)),"",AGGREGATE(14,6,INDEX($B$2:$G$36,0,MATCH($J$3,$B$1:$G$1,0)),ROWS(J$22:J22)))
K22:K31K22=IF(J22="","",INDEX($B$2:$G$36,MATCH(I22,$A$2:$A$36,0),MATCH($J$6,$B$1:$G$1,0)))
L22:L31L22=IF(K22<LARGE($K$22:$K$31,5),"",IF(K22="","",COUNTIFS($J$22:$J$31,">"&J22)+COUNTIFS($J$22:$J$31,J22,$K$22:$K$31,">"&K22)+COUNTIFS($J$22:$J22,J22,$K$22:$K22,K22)))
Named Ranges
NameRefers ToCells
_FilterDatabase=Sheet13!$A$1:$G$36I22:I31
Cells with Conditional Formatting
CellConditionCell FormatStop If True
J9:O18Expression=AND(J$8=$J$6,J9<>"")textNO
J9:O18Expression=AND(J$8=$J$3,J9<>"")textNO
Cells with Data Validation
CellAllowCriteria
J3,J6List=$B$1:$G$1
 
Last edited:
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Forum statistics

Threads
1,224,823
Messages
6,181,180
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