Find the second highest attribute based on criteria. I know its a combo of index(match(large, but I just can't get it to work correctly.

InquisitiveFrog

New Member
Joined
Apr 20, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I have a large list of citizen names that are associated with eleven different attributes. I'm trying to find the best fit job for them based on each job having two defining attributes. This is what the 'Citizens Stats' tab looks like:
Stats Tab.jpg


L4 =LARGE(Adaptability,L3)
L5 =COUNTIF(Adaptability,">="&L4)
Rank =IF(ROWS('Citizens Stats'!$A$41:A46)>COUNTIF(Adaptability,">="&LARGE(Adaptability,$L$3)),"",ROWS('Citizens Stats'!$A$41:A46))
Adaptability =IF(K8="","",LARGE(Adaptability,K8))
Name =IF(K8="","",INDEX(Name,AGGREGATE(15,6,(ROW(Name)-ROW('Citizens Stats'!$A$2)+1)/(Adaptability=Ranks!L8),COUNTIF(Ranks!$L$8:L8,Ranks!L8))))

Ranks Tab.jpg


I created a 'Ranks' tab where I first determined how many jobs needed a primary stat. In this case, four jobs ("Top") require a high "Adaptability" score. Then I determined what the highest score for Adaptability was 40, using the Large function. In order to account for duplicates I figured out how many scores matched the top score. For the Rank column I wanted it to change based on how many top scores I needed for jobs. I then added the top 4 scores, which all happened to be 40 in this instance and matched their name with their score taking duplicates into account. I am now trying to search the citizen tab based on the Name criteria to find their second highest score and attribute name. I was able to accomplish this on another sheet, but it requires that all 150 names are in alphabetical order since it is a row based search (2nd Score =LARGE('Citizens Stats'!B2:L2, 2), 2nd Stat =INDEX('Citizens Stats'!$B$1:$L$1,MATCH(LARGE('Citizens Stats'!B2:L2,2),'Citizens Stats'!B2:L2,0)) - although there was a problem with duplicates getting ignored which led me to trying the method outlined at the start of this paragraph. I just want to be able to give them their best job...based on their two highest scores. No rush, this is just me having fun in excel....
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Welcome to the Forum!

Perhaps something along these lines?

ABCDEFG
1NamePQRST
2A3030322129
3B1832353525
4C343411913
5D2320363135
6E33623178
7F273332733
8G57233223
9H40831833
10I1832141211
11J3639284031
12K29625256
13L121302230
14M26733424
15N10553531
16O39411816
17
18Criteria
19Chosen ScoreQ
20Large (N)4
21Highest
22QNot Q
23NamesB3235R,S
24C3434P
25E3623R
26I3218P
27J3940S
Sheet1
Cell Formulas
RangeFormula
D22D22=C19
C23:C27C23=LET(x,XLOOKUP(Score,C1:G1,C2:G16),FILTER(A2:A16,x>=LARGE(x,N)))
D23:D27D23=XLOOKUP(C23#,A2:A16,XLOOKUP(Score,C1:G1,C2:G16))
E22E22="Not "&Score
E23:F27E23=LET(x,XLOOKUP(C23,A$2:A$16,C$2:G$16)*(C$1:G$1<>Score),CHOOSE({1,2},MAX(x),TEXTJOIN(",",,FILTER(C$1:G$1,x=MAX(x)))))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
N=Sheet4!$C$20C23
Score=Sheet4!$C$19C23:D23, D22:E22, E23:E27
 
Upvote 0

Forum statistics

Threads
1,215,420
Messages
6,124,800
Members
449,189
Latest member
kristinh

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