如何将过滤器公式创建为arrayformula

时间:2019-06-25 22:03:58

标签: regex google-sheets google-sheets-formula array-formulas google-sheets-query

我有多个列取决于此公式。

我有一个实例,一个雇员可以为同一个项目分配多个任务,我使用公式合并行并在相应行中添加导致额外行的值: enter image description here

我首先执行= Unique(A3:D)来提取列表,然后:

=IF($A3<>"",join(", ",filter(Sheet1!E$3:E,Sheet1!$A$3:$A=$G3)),"")

如何使它成为ArrayFormula? 我这样尝试过,但结果不正确:

=arrayformula(IF($A2:A<>"",join(", ",filter(Sheet1!E$2:E,Sheet1!$A$2:$A=$G2:G)),""))

这是一个示例电子表格: https://docs.google.com/spreadsheets/d/1cLXNidk6FSZbUeU0CK3XlMPWdpBMbnKMXC5gzTfMvY0/edit?usp=sharing

1 个答案:

答案 0 :(得分:1)

一劳永逸:

=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))), ", ♦", ", "), ",$", ), "♦"))

0


仅列 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)