What I'm trying to do is find the name of the person who is ranked number 1 in the table shown below. I have tried =LOOKUP
and =VLOOKUP
but I get an error saying that a result can't be found, even though it's obviously there. I assume that I'm either using the wrong function or just not using it right.
I tried =VLOOKUP(1;D2:H19;1)
and =LOOKUP(1;D2:H19;1)
but neither seems to work.
CodePudding user response:
Answer
The following formula should produce the behaviour you desire:
=INDEX(D2:D,MATCH(1,H2:H,0))
Explanation
=VLOOKUP
can only be used to find values to the right of a search key. To find values to the left of a search key, use a combination of =INDEX
and =MATCH
.
The =MATCH
function searches a specified range for a specified value and returns the relative position of the value in that range. In this case, the value to search for is 1
, the range to search through is H2:H
, and the 0
at the end specifies that the range is not sorted in any way.
The =INDEX
function returns the contents of a cell within a range having a specified row and column offset. In this case, the range is D2:D
, and the row is whichever row is returned by =MATCH
. =INDEX
could take a third argument if it was desired to specify a row offset as well, but that is not necessary here.
Functions used:
CodePudding user response:
You sort your ascending order based on rank then return your desired data using INDEX()
function. Try-
=INDEX(SORT(D2:H500,5,1),1,1)
CodePudding user response:
You can use query (usefull in case of ex aequo)
=query(D2:H,"select D where H=1",0)
CodePudding user response:
=vlookup(1,{H2:H19, D2:D19},2)
Since vlookup
only searches the 1st column of the input range, to use it, you need to flip the columns by composing a local array: {H2:H19, D2:D19}
.
{}
means concatenation. ,
in it means horizontal concatenation. With that, the rank column is now the 1st column in the input of vlookup
and now vlookup
works.
With our local array, the 2nd column are the names and therefore index should be 2.
Also note the use of comma to separate function inputs.
CodePudding user response:
your VLOOKUP formula should look like:
=VLOOKUP(1, {H2:H19, D2:D19}, 2, 0)
also try just:
=FILTER(D:D; H:H=1)
or:
=SORTN(D:D; 1; 1; H:H; 1)