简体   繁体   English

如何在谷歌表中将 ARRAYFORMULA 与 COUNTIF 一起应用?

[英]How to apply ARRAYFORMULA together with COUNTIF in google sheet?

在此处输入图片说明

Hi everyone,大家好,

I want to count how many Students choose "Yes" and how many Students choose "No".我想计算有多少学生选择“是”,有多少学生选择“否”。 Each student will be given 5 rows, so the formula need to check whether any "Yes" or "No" exist in these 5 rows.每个学生将获得 5 行,因此公式需要检查这 5 行中是否存在“是”或“否”。 Only count once even though there might be more than one "Yes" or "No" for one student.即使一个学生可能有多个“是”或“否”,也只计算一次。

Initially I'm using COUNTIF(B2:B6,"Yes") in column C and then use COUNTIF(C2:C6,"<>0") in column D. Finally, I use COUNTIF(D2:D31,"<>0") to obtain Number of student choose "Yes" or "No".最初我在 C 列中使用COUNTIF(B2:B6,"Yes")然后在 D 列中使用COUNTIF(C2:C6,"<>0") 。最后,我使用COUNTIF(D2:D31,"<>0")获得学生人数选择“是”或“否”。 I think it is to tedious to do it manually, is there any way can make this process simpler, maybe using Arrayformula or Query (Not sure how it can work together with Countif )?我认为手动完成它很乏味,有什么方法可以使这个过程更简单,也许使用ArrayformulaQuery (不确定它如何与Countif一起工作)? Any help will be greatly appreciated!任何帮助将不胜感激!

try:尝试:

=ARRAYFORMULA(TRANSPOSE(QUERY(UNIQUE({IF(B2:B="",, 
 VLOOKUP(ROW(A2:A), IF(A2:A<>"", {ROW(A2:A), A2:A}), 2, 1)), B2:B}), 
 "select count(Col1) where Col2 is not null pivot Col2")))

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM