查找多个项目 [英] Lookup Multiple Items
问题描述
NAME |号
Joe | 1
简| 0
杰克| 1
吉尔| 0
John | 1
我正在查找数字,找出相应的名称
我的公式是
{= index($ A $ 2:$ B $ 6,SMALL(IF($ B $ 2:$ B $ 6 = 1,ROW($ B $ 2:$ B $ 6)),行(1:1)),1)}
据了解公式:
- 第一个Excel运行索引函数。它在数组A2到B6上运行索引函数。
- 对于索引函数中的行号,它使用函数
SMALL(IF($ B $ 2: $ B $ 6 = 1,ROW($ B $ 2:$ B $ 6)),行(1:1)
这将检查一个数组b2:b6,如果B2中考虑的元素: B6是1,它返回行号b2:b6,在这种情况下,它会返回一个2。 - 在这一点上我有点卡住了,我猜第二个ROW函数返回从小函数导出的第一种情况
- 最后,索引函数找到找到的索引的第1列中的名称。
你对这个公式的理解是相当不错的,我假设你要把它复制到足够多的行所有的价值报告?如果是这样,这是发生了什么:
-
INDEX
需要知道要查找哪一行,为了做到这一点,我们要给它一个行号。 - 为了获得行号,我们需要知道哪些项目符合条件。如果满足条件,我们使用
IF
条件来报告行号(否则我们得到FALSE
)。 li>
- 由于这会给我们一列行号,所以我们使用
SMALL
函数给我们一个单个值。这满足INDEX
函数,需要单行检索。 - 所以我们从
小
?嗯,我们只是给它一个1-2-3 -...的序列,使用ROW(1:1)
。当这被复制下来时,它将成为ROW(2:2)
,ROW(3:3)
等这些将分别返回1,2,3,所以我们得到下一个条目。请注意,SMALL
跳过FALSE
,所以它适用于IF $ c的输出$ c> call。
所以第一次调用 ROW
IF
)用于确定数组中匹配条件的值的行。
第二次调用 ROW(1:1)
仅用于获取递增序列一次公式被复制下来。
最后要注意的是,您的公式将在答案上一行因为 ROW($ B $ 2:$ B $ 6)
将返回这些行的绝对行号,而不是相对于感兴趣的数组的起始角。在这种情况下,您需要减去1才能使其工作(因为它从第2行开始)。在一般情况下,使用一个这样的公式计算数组的偏移量:
= INDEX($ A $ 2: $ A $ 6,SMALL(IF($ B $ 2:$ B $ 6 = 1,ROW($ B $ 2:$ B $ 6)-ROW($ B $ 2)+1),ROW(1:1)))
这是一个像你一样的数组公式(用CTRL + SHIFT + ENTER输入)。相应的范围如下所示:
I have a list of names and numbers
NAME | Number
Joe | 1
Jane | 0
Jack | 1
Jill | 0
John | 1
I'm trying to look up the numbers and find out the corresponding name The formula I have is
{=index($A$2:$B$6, SMALL(IF($B$2:$B$6 = 1, ROW ($B$2:$B$6)), Row(1:1)), 1)}
As I understand the formula:
- First Excel runs the index function. It runs the index function on the array A2 through B6.
- For the row number in the index function, it uses the function
SMALL(IF($B$2:$B$6 = 1, ROW ($B$2:$B$6)), Row(1:1)
. This examines an array, b2:b6, and if the element under consideration in B2:B6 is a 1, it returns the row number of b2:b6. In this case, it would return a 2. - At this point I'm kind of stuck. I'm guessing that the second ROW function returns first case of the 1 derived from the small function
- Lastly, the index function finds the name located in column 1 for the index found.
Your understanding of this formula is pretty good. I assume that you are going to copy it down enough rows to get all the values reported? If so, here is what is happening:
INDEX
needs to know what row to go retrieve. In order to do this, we are going to give it a row number.- In order to get a row number we need to know which items meet the condition. We use the
IF
conditional to report a row number if the condition is met (otherwise we getFALSE
). - Since that will give us an array of row numbers, we then use the
SMALL
function to give us a single value. That satisfies theINDEX
function which needs a single row to retrieve. - So which value do we choose from
SMALL
? Well, we just give it a sequence of 1-2-3-... by usingROW(1:1)
. When this is copied down, it will becomeROW(2:2)
,ROW(3:3)
, etc. Each of these will return 1, 2, 3, respectively so we get the next entry. Note thatSMALL
skipsFALSE
so it works for the output of theIF
call.
So the first call to ROW
(inside the IF
) is used to determine the row of the values in the array that match the condition.
The second call to ROW(1:1)
is just used to get an incrementing sequence once the formula is copied down.
The final thing to note is that your formula will be off by one row on the answers because ROW($B$2:$B$6)
will return the absolute row number of those rows and not one that is relative to the starting corner of the array of interest. In this case, you will need to subtract 1 to get it to work (since it starts in row 2). In the general case, use a formula like this which accounts for the offset of the array:
=INDEX($A$2:$A$6,SMALL(IF($B$2:$B$6=1,ROW($B$2:$B$6)-ROW($B$2)+1),ROW(1:1)))
That is an array formula like you have (enter with CTRL+SHIFT+ENTER). The corresponding ranges look like:
这篇关于查找多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!