简体   繁体   中英

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 %. 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 is not always in Agent 4. Any agent can be in Agent 2, Agent 3, or Agent 4 for a given Client.

在此处输入图片说明

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

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:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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