大家好,
我的目标是计算选择行动 3 作为他们的答案之一但之前的答案不是行动 2 的学生人数。
因此根据上面屏幕截图中的示例,Mary
、Lary
和 yuki
选择操作 3 作为其答案之一,但只有 Lary
将操作 2 作为他之前的回答。因此,单元格 B2
中的预期输出为 2
,因为在 Action 3 之前 Mary
的上一个答案是 Action 5 而不是 Action 2 而对于 yuki
,则是 Action 之前的上一个答案3 是行动 1 而不是行动 2。
我可以知道如何自动化这个公式吗?我不知道如何开始构建这个公式。
这是我的谷歌表:https://docs.google.com/spreadsheets/d/1Zk7lr_2lEKEyY6qI0kNVXBHRF7mcsBJGDyR0BQjKyk0/edit#gid=0
任何帮助将不胜感激!
答案 0 :(得分:1)
试试:
=query({{offset(A4:C,1,0);"","",""},C4:C},"select count(Col1) where Col3 matches 'Action 3' and not Col4 matches 'Action 2' label count(Col1) '' ",1)
对于同一个学生,尝试:
=query({{query({A4:C},"where Col1 is not null order by Col2,Col1 offset 1",1);"","",""},query({A4:C},"where Col1 is not null order by Col2,Col1",1)},"select count(Col1) where Col2=Col5 and Col3 matches 'Action 3' and not Col6 matches 'Action 2' label count(Col1) '' ",1)
要查看结果,而不是计算结果:
=query({{query({A4:C},"where Col1 is not null order by Col2,Col1 offset 1",1);"","",""},query({A4:C},"where Col1 is not null order by Col2,Col1 label Col3 'Prev answer'",1)},"select * where Col2=Col5 and Col3 matches 'Action 3' and not Col6 matches 'Action 2' label count(Col1) '' ",1)
答案 1 :(得分:1)
根据您在原始帖子下的评论部分对我的问题的回复,我在您的示例电子表格中添加了一个新工作表(“Erik 帮助”),在 B2 中使用以下公式(当前以亮绿色突出显示):
=ArrayFormula(SUM((C5:C="Action 3")*(IFERROR(VLOOKUP(ROW(A5:A)-1,{ROW(A5:A),C5:C},2,FALSE)<>"Action 2",0))*(IFERROR(VLOOKUP(ROW(A5:A)-1,{ROW(A5:A),B5:B},2,FALSE)=B5:B,0))))
附录(阅读其他评论后):
我使用以下公式添加了一个新工作表(“Erik Help 2”):
=COUNTA(UNIQUE(FILTER(B5:B,C5:C="Action 3",VLOOKUP(ROW(A5:A)-1,{ROW(A5:A),B5:B&C5:C},2,FALSE)<>B5:B&"Action 2")))