简体   繁体   English

我怎样才能找到排名第一的人的名字?

[英]How can I find the name of the person ranked 1?

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.我已经尝试过=LOOKUP=VLOOKUP ,但我收到一条错误消息,指出无法找到结果,即使它显然存在。 I assume that I'm either using the wrong function or just not using it right.我假设我要么使用了错误的 function,要么只是没有正确使用它。

I tried =VLOOKUP(1;D2:H19;1) and =LOOKUP(1;D2:H19;1) but neither seems to work.我尝试了=VLOOKUP(1;D2:H19;1)=LOOKUP(1;D2:H19;1)但似乎都不起作用。

在此处输入图像描述

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. =VLOOKUP只能用于查找搜索键右侧的值。 To find values to the left of a search key, use a combination of =INDEX and =MATCH .要查找搜索键左侧的值,请结合使用=INDEX=MATCH

The =MATCH function searches a specified range for a specified value and returns the relative position of the value in that range. =MATCH function 在指定范围内搜索指定值,并返回该范围内值的相对值 position。 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.在这种情况下,要搜索的值为1 ,要搜索的范围为H2:H ,末尾的0指定该范围不以任何方式排序。

The =INDEX function returns the contents of a cell within a range having a specified row and column offset. =INDEX function 返回具有指定行和列偏移量的范围内的单元格内容。 In this case, the range is D2:D , and the row is whichever row is returned by =MATCH .在这种情况下,范围是D2:D ,行是=MATCH返回的行。 =INDEX could take a third argument if it was desired to specify a row offset as well, but that is not necessary here.如果还需要指定行偏移量, =INDEX可以采用第三个参数,但这在这里不是必需的。

Functions used:使用的函数:

You sort your ascending order based on rank then return your desired data using INDEX() function. Try-您根据排名对升序进行排序,然后使用INDEX() function 返回所需的数据。尝试-

=INDEX(SORT(D2:H500,5,1),1,1)
=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} .由于vlookup仅搜索输入范围的第一列,因此要使用它,您需要通过组成本地数组来翻转列: {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.这样,排名列现在是vlookup输入中的第一列,现在vlookup可以工作了。

With our local array, the 2nd column are the names and therefore index should be 2.对于我们的本地数组,第二列是名称,因此索引应为 2。

Also note the use of comma to separate function inputs.另请注意使用逗号分隔 function 输入。

You can use query (usefull in case of ex aequo)您可以使用查询(在 ex aequo 的情况下很有用)

=query(D2:H,"select D where H=1",0)

your VLOOKUP formula should look like:您的 VLOOKUP 公式应如下所示:

=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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM