Search for data in a matrix from several parameters.

quemuenchatocha

Board Regular
Joined
Aug 4, 2021
Messages
50
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Dear all, have a nice day.

I appreciate any information you can give me about the following question.

I am performing a search process that allows me to find, within a set of students [A2:A9], who obtained the highest grade [B2:I9], for a set of subjects [B1:I1]. I found a solution, but it requires to know first the name of the student [H11] or very well the name of the subject [K11].

Student data.xlsx
ABCDEFGHIJK
1NameLab 1Lab 2Lab 3HW 1HW 2HW 3Exam 1Exam 2
2Jim948,52324229087
3Henry87,5102020248794,5
4Sally108,59,52123,519,57884
5Pinocchio7,5107,52519219591,5
6Heather89102320,5239396
7Ella9,51010221920,510099
8Tom8,56,58,52424,523,587,598,5
9Nancy108920,523,5248295
10
11Maximum:100StudentEllaSignatureExam 1
12Who?:EllaMax Score100Max Score100
13Assignment:Exam 1SignatureExam 1StudentElla
14
Grades
Cell Formulas
RangeFormula
C11C11=MAX(B2:I9)
C12C12=INDEX(A2:A9,MATCH(C11,OFFSET(A1,1,7,8,1),0))
C13C13=INDEX(B1:I1,MATCH(C11,OFFSET(B1,MATCH(C12,A2:A9,0),0,1,8)))
H12H12=MAX(OFFSET(A1,MATCH(H11,$A$2:$A$9,0),1,1,8))
H13H13=INDEX(B1:I1,MATCH(H12,OFFSET(A1,MATCH(H11,A2:A9,0),1,1,8),0))
K12K12=MAX(OFFSET(A1,1,MATCH(K11,B1:I1,0),8,1))
K13K13=INDEX(A2:A9,MATCH(K12,OFFSET(A1,1,MATCH(K11,B1:I1,0),8,1),0))
Cells with Data Validation
CellAllowCriteria
H11List=$A$2:$A$9
K11List=$B$1:$I$1


My question is focused then on knowing if it is possible only from the maximum score [C11], to know which was the student (name) who obtained the maximum grade [C12]?

I tried the following formula C12=INDEX(A2:A9,MATCH(C11,OFFSET(A1,1,7,8,1),0)), but it is clear that the values entered in the OFFSET function for Row and Column are previously known, so it is not the procedure I am looking for.

Thank you very much for your attention.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
How about in C12
Excel Formula:
=INDEX(A2:A9,AGGREGATE(15,6,(ROW(A2:A9)-ROW(A2)+1)/(B2:I9=C11),1))
and C13
Excel Formula:
=INDEX(B1:I1,AGGREGATE(15,6,(COLUMN(B1:I1)-COLUMN(B1)+1)/(A2:A9=C12)/(B2:I9=C11),1))
 
Upvote 0
Solution
An alternative is to use Power Query
Excel 2016 (Windows) 32 bit

A
B
C
12
AttributeMax GradeTable1 (2).Name
13
Exam 1
100​
Ella
14
Exam 2
99​
Ella
15
HW 1
25​
Pinocchio
16
HW 2
24.5​
Tom
17
HW 3
24​
Henry
18
HW 3
24​
Nancy
19
Lab 1
10​
Nancy
20
Lab 1
10​
Sally
21
Lab 2
10​
Pinocchio
22
Lab 2
10​
Ella
23
Lab 3
10​
Henry
24
Lab 3
10​
Ella
25
Lab 3
10​
Heather

Sheet: Sheet1

Unpivot your data in Power Query and then join the unpivoted data back against the original table.

Here are the Mcodes if you wish to go down that road

Unpivot original table and group to find Max score
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"Lab 1", type number}, {"Lab 2", type number}, {"Lab 3", type number}, {"HW 1", type number}, {"HW 2", type number}, {"HW 3", type number}, {"Exam 1", type number}, {"Exam 2", type number}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Name"}, "Attribute", "Value"),
    #"Grouped Rows" = Table.Group(#"Unpivoted Other Columns", {"Attribute"}, {{"Max Grade", each List.Max([Value]), type number}})
in
    #"Grouped Rows"

Take original table and unpivot only with a new name.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Name"}, "Attribute", "Value")
in
    #"Unpivoted Other Columns"

Now join the two tables to find who had the high scores.

Power Query:
let
    Source = Table.NestedJoin(Table1, {"Attribute", "Max Grade"}, #"Table1 (2)", {"Attribute", "Value"}, "Table1 (2)", JoinKind.LeftOuter),
    #"Expanded Table1 (2)" = Table.ExpandTableColumn(Source, "Table1 (2)", {"Name"}, {"Table1 (2).Name"}),
    #"Sorted Rows" = Table.Sort(#"Expanded Table1 (2)",{{"Attribute", Order.Ascending}})
in
    #"Sorted Rows"
 
Upvote 0
How about in C12
Excel Formula:
=INDEX(A2:A9,AGGREGATE(15,6,(ROW(A2:A9)-ROW(A2)+1)/(B2:I9=C11),1))
and C13
Excel Formula:
=INDEX(B1:I1,AGGREGATE(15,6,(COLUMN(B1:I1)-COLUMN(B1)+1)/(A2:A9=C12)/(B2:I9=C11),1))
Dear @Fluff , thank you very much for your valuable collaboration, it has been useful to solve my doubt.
 
Upvote 0
Dear @alansidman you are very kind to teach me this solution, personally I have little knowledge about Power Query, it is something I have pending to learn, I would like if possible, give me some tips (blogs, tutorials,...) to start with training in this valuable tool, thanks for your collaboration.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Upvote 0

Forum statistics

Threads
1,224,816
Messages
6,181,141
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