我有一个简单的Google表格电子表格,可以跟踪一群人完成的任务。当每个人完成一项任务时,我都使用一个简单的复选框标记完成情况:
RxSwift
我正在寻找一种方法来编写一个最终专栏,以总结哪些任务尚未完成,例如:
Task: A B C D
Human 1 [x] [] [] []
Human 2 [x] [x] [x] []
Human 3 [] [x] [] [x]
Human 4 [x] [x] [x] [x]
我的目标是使用单个公式来完成此操作,该公式将遍历每一行并将未选中的框的列名连接起来。
我尝试将Task: A B C D Not Yet Completed:
Human 1 [x] [] [] [] B, C, D
Human 2 [x] [x] [x] [] D
Human 3 [] [x] [] [x] A, C
Human 4 [x] [x] [x] [x] (Blank)
与ARRAYFORMULA
结合使用,如下所示:
TEXTJOIN
这完成了我想要的,但是要求我将该公式复制到要跟踪的每一行中。
当我尝试将文本联接应用于二维范围时,它将把所有文本联接到单个单元格中,而不是将其逐行应用于每一行:
=TEXTJOIN(", ", TRUE, ARRAYFORMULA(IF(B2:E2=FALSE,$B$1:$E$1,"")))
相比之下,当我在“条件格式设置”中设置自定义公式时,它允许我“应用于范围”(即,在多行中),但随后输入仅限于单行的公式。然后,它将公式逐个应用于每一行。
是否可以使用=TEXTJOIN(", ", TRUE, ARRAYFORMULA(IF(B2:E5=FALSE,$B$1:$E$1,"")))
---Result---
Task: A B C D Not Yet Completed:
Human 1 [x] [] [] [] B, C, D, D, A, C
Human 2 [x] [x] [x] []
Human 3 [] [x] [] [x]
Human 4 [x] [x] [x] [x]
或Google表格本身的其他功能在单元格中执行相同的“应用于范围”概念?
答案 0 :(得分:1)
尝试:
=ARRAYFORMULA(REGEXREPLACE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(
IF((B2:E<>"")*(B2:E=FALSE), B1:E1&",", )),,999^99))), ",$", ))
答案 1 :(得分:0)
困难的方法:使用&(如果列数固定,这将起作用,否则必须不断更新公式)
={"Not Yet Completed:";arrayformula(if(A2:A="","",substitute(trim(if(B2:B," ",B1&" ")&if(C2:C," ",C1&" ")&if(D2:D," ",D1&" ")&if(E2:E," ",E1&" "))," ",", ")))}
简单方法:使用查询标头(与player0答案大致相同,但执行方法略有替代)
={"Not Yet Completed:";arrayformula(if(A2:A="","",substitute(trim(transpose(query(transpose(if(B2:E5,"",B1:E1)),"",columns(B1:E1))))," ",", ")))}