简体   繁体   中英

Excel array formula to multi dimensional intermediate arrays

I have the following data

在此处输入图片说明

What I want to achieve is these intermediate arrays

在此处输入图片说明

ie for JohnProject there are two entries A and C. For Project A there are two tags 10 and 6 in the 2nd table, and for Project C there are three tags 22,9,7. I want to get these as intermediate arrays in a bigger array formula.

With array formula

=UNIQUE(IF({"D"}=D2:D9,ROW(D2:D9)))

I can achieve the closer result for JuliaProject D and 4,8 but for any other who has two projects it doesnt work.

=UNIQUE(IF({"A","C"}=D2:D9,ROW(D2:D9)))

I want to have intermediate results in the form for arrays to be used in other array formula.

EDIT: The complex version of my problem.

Ok for the bigger problem. Its a bit complex to explain. But I can try. I have a mapping table, truth table and Input data. I want to find if the input data can be mapped using the truth table and mapping table. So its a bit of a mapping I want to achieve at the end. Mapping table itself is a many-many where one project can have multiple tags, as well as one tag can associated with multiple projects, but there is no Person in there. Purely projects and tags. The truth table has Person and Projects but not the tags. I want to map From the Unique person to a Tag. I can easily get all the projects associated with one person (In array formula as an intermediate array) and now for each project that I get in an array I want to find out all the tags and make them consolidated in one array. The problem lies in the many-many relationship in the mapping table, as it returns multidimensional array as a result not a single dimension. I want to get an array (intermediate in array formula) to finally search if a claimed tag is in that list. I hope it makes sense.

The following array formula can be used to join USER with a TAG:

{=AGGREGATE(15,6,INDEX($E$2:$E$9,N(IF(MMULT(--IFERROR(TRANSPOSE(INDEX($B$2:$B$6,N(IF($G2=$A$2:$A$6,ROW($B$2:$B$6)))-1))=$D$2:$D$9,FALSE),ROW($B$2:$B$6)^0),ROW($D$2:$D$9)))-1),COLUMNS($G$2:G2))}

I don't know where the formula will be used next, but to display the result I put it into the AGGREGATE function. Without AGGREGATE , the array is returned including error values.

"Clean" formula:

{=INDEX($E$2:$E$9,N(IF(MMULT(--IFERROR(TRANSPOSE(INDEX($B$2:$B$6,N(IF($G2=$A$2:$A$6,ROW($B$2:$B$6)))-1))=$D$2:$D$9,FALSE),ROW($B$2:$B$6)^0),ROW($D$2:$D$9)))-1)}

在此处输入图片说明

The following formula will display "Array result without error values" by hitting the highlighted formula inside the formula bar with keystroke F9

1] "Project" array result, in H2 formula copied down :

=INDEX(B$2:B$6,N(IF(1,AGGREGATE(15,6,ROW(B$1:B$5)/($A$2:$A$6=G2),ROW(INDIRECT("1:"&COUNTIF(A$2:A$6,G2)))))))

2] "Tag" array result, in I2 formula copied down :

=INDEX(E$2:E$9,N(IF(1,AGGREGATE(15,6,ROW(E$1:E$8)/ISNUMBER(MATCH(D$2:D$9,IF(A$2:A$6=G2,B$2:B$6),0)),ROW(INDIRECT("1:"&COUNT(MATCH(D$2:D$9,IF(A$2:A$6=G2,B$2:B$6),0))))))))

在此处输入图片说明

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