简体   繁体   English

索引匹配数组:索引范围和多个匹配项

[英]Index Match Array: Index Range And Multiple Matches

I have a block of data in the following layout on tab Group Commissions (I'm attaching a photo as well.). 我在“小组佣金”标签上的以下布局中有一个数据块(我也附有一张照片。)。 On a separate tab named for the agent Paul, I'm trying to cross reference the Client Name in cell B11 and the Agent name in cell B4 with the data on Group Commissions to return a specific agent's Commission %. 在一个为代理Paul命名的单独选项卡上,我试图将B11单元格中的“客户名”和B4单元格中的“代理人”名称与组佣金中的数据进行交叉引用,以返回特定代理人的佣金%。 So if on tab Paul I have "Client 1" in B11 and "Paul" in B4, I want to be able to return "12.5". 因此,如果在Paul选项卡上我在B11中具有“客户端1”,在B4中具有“ Paul”,那么我希望能够返回“ 12.5”。 Paul is not always in Agent 4. Any agent can be in Agent 2, Agent 3, or Agent 4 for a given Client. Paul并不总是在Agent 4中。对于给定的客户,任何Agent都可以在Agent 2,Agent 3或Agent 4中。

在此处输入图片说明

I have this formula working, but it's not quite what I want, because I can't hard code the row numbers. 我有这个公式,但是它不是我想要的,因为我不能对行号进行硬编码。

{=INDEX('Group Commissions'!G:I,MATCH('Paul'!B11,'Group Commissions'!A:A,0),MATCH(B4,'Group Commissions'!C143:E143,0))}

However, using a range of columns causes the formula to error out. 但是,使用一定范围的列会导致公式错误。 As I mentioned, I cannot hard code for row numbers so now I'm stuck. 正如我所提到的,我无法对行号进行硬编码,因此现在我陷入了困境。 Is this even possible? 这有可能吗?

{=INDEX('Group Commissions'!G:I,MATCH('Paul'!B11,'Group Commissions'!A:A,0),MATCH(B4,'Group Commissions'!C:E,0))}

=INDEX('Group Commissions'!G1:I5,MATCH(Paul!B11,'Group Commissions'!A1:A5,0),SMALL(IF(Paul!B4=IF('Group Commissions'!A1:A5=Paul!B11,'Group Commissions'!C1:E5),IF('Group Commissions'!A1:A5=Paul!B11,COLUMN('Group Commissions'!C1:E5)-COLUMN(C:C)+1)),1))

Okay, this is a bit messy but achieves what you are looking for. 好的,这有点混乱,但是可以满足您的需求。

For the second argument (column number) I have had to use a nested IF() statement to build an array of column numbers (offest to the start of the INDEX() clause, used column calculations for ease of reading only, I would normally subtract the number required). 对于第二个参数(列号),我不得不使用嵌套的IF()语句来构建列号数组(距离INDEX()子句的开头最近,使用列计算只是为了便于阅读,我通常会减去所需的数字)。

I first produce an array of FALSE for all cells for rows that do match the client and the correct values for rows that do: 我首先为与客户端匹配的行的所有单元格生成FALSE数组,为与客户端匹配的行的正确值生成FALSE数组:

IF('Group Commissions'!A1:A5=Paul!B11,'Group Commissions'!C1:E5)

I then check this array for the agent name and equate that against the column numbers that I want returned (same formula but returning column number minus the index offset): 然后,我检查此数组的代理名称,并将其与我要返回的列号等同(相同的公式,但返回的列号减去索引偏移量):

IF(Paul!B4=[Previus part],IF('Group Commissions'!A1:A5=Paul!B11,COLUMN('Group Commissions'!C1:E5)-COLUMN(C:C)+1)

This is wrapped in SMALL() so we can return the smallest result (putting numbers first) so we get the column number as the result. 它包装在SMALL()因此我们可以返回最小的结果(首先输入数字),因此我们获得列号作为结果。

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

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