Reputation: 329
I have multiple columns that depend on this formula.
I have instances were an employee can have multiple assignments for the same Project and I use the formula to consolidate the rows and add the value that causes an extra row in the corresponding row:
I first perform a = Unique(A3:D)
to extract the list and then:
=IF($A3<>"",join(", ",filter(Sheet1!E$3:E,Sheet1!$A$3:$A=$G3)),"")
How can I make this an ArrayFormula? I tried it like this but the result is incorrect:
=arrayformula(IF($A2:A<>"",join(", ",filter(Sheet1!E$2:E,Sheet1!$A$2:$A=$G2:G)),""))
Here's an example spreadsheet: https://docs.google.com/spreadsheets/d/1cLXNidk6FSZbUeU0CK3XlMPWdpBMbnKMXC5gzTfMvY0/edit?usp=sharing
Upvotes: 1
Views: 622
Reputation: 1
do it all in one go:
=ARRAYFORMULA(SPLIT(REGEXREPLACE(SUBSTITUTE(TRIM(TRANSPOSE(QUERY(TRANSPOSE({
QUERY(QUERY(IF(A3:A<>"", {A3:A&"♦"&B3:B&"♦"&C3:C&"♦"&D3:D, E3:E}, ),
"select Col1,count(Col1) where Col1 is not null group by Col1 pivot Col2", 0),
"select Col1 offset 1", 0),
IF(QUERY(QUERY(IF(A3:A<>"", {A3:A&"♦"&B3:B&"♦"&C3:C&"♦"&D3:D, E3:E}, ),
"select count(Col1) where Col1 is not null group by Col1 pivot Col2", 0), "offset 1",0)<>"",
QUERY(QUERY(IF(A3:A<>"", {A3:A&"♦"&B3:B&"♦"&C3:C&"♦"&D3:D, "♦"&E3:E&","}, ),
"select count(Col1) where Col1 is not null group by Col1 pivot Col2", 0), "limit 0",1), )})
,,999^99))), ", ♦", ", "), ",$", ), "♦"))
only column K:
=QUERY(ARRAYFORMULA(SPLIT(REGEXREPLACE(SUBSTITUTE(TRIM(TRANSPOSE(QUERY(TRANSPOSE({
QUERY(QUERY(IF(A3:A<>"", {A3:A&"♦"&B3:B&"♦"&C3:C&"♦"&D3:D, E3:E}, ),
"select Col1,count(Col1) where Col1 is not null group by Col1 pivot Col2", 0),
"select Col1 offset 1", 0),
IF(QUERY(QUERY(IF(A3:A<>"", {A3:A&"♦"&B3:B&"♦"&C3:C&"♦"&D3:D, E3:E}, ),
"select count(Col1) where Col1 is not null group by Col1 pivot Col2", 0), "offset 1",0)<>"",
QUERY(QUERY(IF(A3:A<>"", {A3:A&"♦"&B3:B&"♦"&C3:C&"♦"&D3:D, "♦"&E3:E&","}, ),
"select count(Col1) where Col1 is not null group by Col1 pivot Col2", 0), "limit 0",1), )})
,,999^99))), ", ♦", ", "), ",$", ), "♦")), "select Col5", 0)
Upvotes: 1