需要将3个公式合并为1

时间:2019-07-08 01:32:40

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

公式1:在Estimate标签中列出所有项目

=QUERY(Estimate!A2:D50,"SELECT * where C is not null",0)

公式2:在taskItemAssociations内找到任务组匹配项

=ARRAYFORMULA(IFERROR(VLOOKUP(A9:A&B9:B&C9:C&D9:D, 
 TRIM(IFERROR(SPLIT(TRIM(TRANSPOSE(QUERY(TRANSPOSE(
 {INDEX(QUERY(IFERROR(SPLIT(SORT(UNIQUE(IF((LEN('task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&'task-itemAssociations'!D2:D))*(LEN('task-itemAssociations'!E2:E)), 
 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&'task-itemAssociations'!D2:D&"♦"&'task-itemAssociations'!E2:E, )), 1, 1), "♦")), 
 "select Col1,count(Col1) where Col1 is not null group by Col1 pivot Col2", 0),,1), IF(
 ISNUMBER(QUERY(IFERROR(SPLIT(SORT(UNIQUE(IF((LEN('task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&'task-itemAssociations'!D2:D))*(LEN('task-itemAssociations'!E2:E)), 
 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&'task-itemAssociations'!D2:D&"♦"&'task-itemAssociations'!E2:E, )), 1, 1), "♦")), 
 "select count(Col1) where Col1 is not null group by Col1 pivot Col2", 0)),
 QUERY(IFERROR(SPLIT(SORT(UNIQUE(IF((LEN('task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&'task-itemAssociations'!D2:D))*(LEN('task-itemAssociations'!E2:E)), 
 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&'task-itemAssociations'!D2:D&"♦♥"&'task-itemAssociations'!E2:E, )), 1, 1), "♦")),
 "select count(Col1) where Col1 is not null group by Col1 pivot Col2 limit 0", 0), )})
 ,,999^99))), "♥"))), {2}, 0)))

公式3:在taskData标签中列出所有匹配项

这个结果确实是我所需要的。我不确定在没有上述所有条件的情况下还有什么其他方法可以到达这里。

=QUERY(taskData!C2:O,"SELECT * where C = '"&E9&"'",0)

enter image description here 理想情况下,这应该是ARRAYFORMULA中的一个Tasks!A2(当前由音符占据)

这里是my sheet

1 个答案:

答案 0 :(得分:2)

粘贴在 A2 单元格中:

=FILTER(taskData!C2:O, REGEXMATCH(taskData!C2:C, TEXTJOIN("|", 1, 
 ARRAYFORMULA(IFERROR(VLOOKUP(
 INDEX(QUERY(Estimate!A2:D50,"where C is not null",0),,1)&
 INDEX(QUERY(Estimate!A2:D50,"where C is not null",0),,2)&
 INDEX(QUERY(Estimate!A2:D50,"where C is not null",0),,3)&
 INDEX(QUERY(Estimate!A2:D50,"where C is not null",0),,4), 
 TRIM(IFERROR(SPLIT(TRIM(TRANSPOSE(QUERY(TRANSPOSE(
 {INDEX(QUERY(IFERROR(SPLIT(SORT(UNIQUE(IF((LEN(
 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&
 'task-itemAssociations'!D2:D))*(LEN('task-itemAssociations'!E2:E)), 
 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&
 'task-itemAssociations'!D2:D&"♦"&'task-itemAssociations'!E2:E, )), 1, 1), "♦")), 
 "select Col1,count(Col1) where Col1 is not null group by Col1 pivot Col2", 0),,1), IF(
 ISNUMBER(QUERY(IFERROR(SPLIT(SORT(UNIQUE(IF((LEN(
 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&
 'task-itemAssociations'!D2:D))*(LEN('task-itemAssociations'!E2:E)), 
 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&
 'task-itemAssociations'!D2:D&"♦"&'task-itemAssociations'!E2:E, )), 1, 1), "♦")), 
 "select count(Col1) where Col1 is not null group by Col1 pivot Col2", 0)),
 QUERY(IFERROR(SPLIT(SORT(UNIQUE(IF((LEN(
 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&
 'task-itemAssociations'!D2:D))*(LEN('task-itemAssociations'!E2:E)), 
 'task-itemAssociations'!A2:A&'task-itemAssociations'!B2:B&'task-itemAssociations'!C2:C&
 'task-itemAssociations'!D2:D&"♦♥"&'task-itemAssociations'!E2:E, )), 1, 1), "♦")),
 "select count(Col1) where Col1 is not null group by Col1 pivot Col2 limit 0", 0), )})
 ,,999^99))), "♥"))), {2}, 0))))))

0