简体   繁体   中英

Excel array function return all fields found with index and match

Here is the array function I am using:

=IFERROR(INDEX('Master Data'!$D$2:$D$153,MATCH(1,(B9='Master Data'!$J$2:$J$153)*('Master Data'!$W$2:$W$153=1),FALSE)),"")

Where D is the name of a project, J is a persons name and W is a flag to check if they are assigned to a project either equal to 0 or 1. B is also an instance of the persons name that is built up from a seperate list.

It basically references the master data and returns any rows with the criteria specified. However a single person may have two instances where the assigned flag is equal to 1 and thus as the master data is filtered different results are given back by the function.

Another problem I have is that the persons name is not repeated either so maybe the best way would be to start populating the names in the assigned table from the master data as well.

As requested here is an slight example of the data. On the left is the master data, the middle is the assigned table thats being built and the right is the list of employees that builds up the names in the assigned table.

数据样本

Please note that there is two instances of david smith in the master data but only one in the assigned table as its being built with the employees list.

What I was thinking was to build up the names in the assigned table from the master data using an array where the assigned indicator is equal to 1 and to completely scrap the employees list, but I'm really unsure if this is possible or how to go about it.

Or even if there was some sort of way to select a few columns from the master data where the assigned indicator = 1?

Not sure if I understood it right. But the problem how to list multiple lookup results is achievable with SMALL function in combination with getting an array of ROW numbers.

For example have a sheet like this:

在此处输入图片说明

Then formulas are:

F4 downwards:

=COUNTIFS($B:$B,$E4,$C:$C,1)

G4 and then copied in G4:J8:

{=INDEX($A$1:$A$1000,SMALL(IF($B$1:$B$1000=$E4,IF($C$1:$C$1000=1,ROW($1:$1000))),COLUMN(A:A)))}

But if the goal is only to have a filtered list of all assigned resources, then the formulas could be

E13:

{=INDEX($B$1:$B$1000,MATCH(1,($C$1:$C$1000=1)*1,0))}

E14 downwards:

{=INDEX($B$1:$B$1000,MATCH(1,(COUNTIF($E$13:$E13,$B$1:$B$1000)=0)*($C$1:$C$1000=1),0))}

Formulas in {} are array formulas. These are entered into the cell without the curly brackets and then [Ctrl]+[Shift]+[Enter] is pressed to finish.

I have not handled the error values for better understanding the formulas. You can later hide the error values with IFERROR. You seems to know how to do this.

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