英文:
In Google Sheets, what formula would let me check if all rows that have a given value in one column also have a specific value in another?
问题
在Sheet1上列出了一组具有任意数量子任务的任务。我想要在Sheet2上得到任务的简单列表,并准确指示哪些任务的所有子任务都已完成。我应该使用什么公式来实现这个功能?
我考虑使用COUNTIFS的某个版本,但不确定如何将其构建成一个IF公式。
英文:
I have a set of tasks with an arbitrary number of subtasks listed on Sheet1. I want the simple list of tasks on Sheet2 to indicate accurately which ones have all subtasks completed. What formula should I use to do this?
I am thinking some version of COUNTIFS, but I am not sure how to formulate it into an IF formula.
答案1
得分: 1
你需要逻辑的 AND()
操作。尝试使用 MAP()
和 FILTER()
。
=MAP(A2:A5,LAMBDA(x,AND(FILTER(Sheet1!B2:B,Sheet1!A2:A=x))))
为了将完整列作为输入用于庞大且不断增长的数据集,尝试以下方法:
=MAP(A2:INDEX(A2:A,COUNTA(A2:A)),LAMBDA(x,AND(FILTER(Sheet1!B2:B,Sheet1!A2:A=x))))
英文:
You need logical AND()
operation. Try with MAP()
and FILTER()
.
=MAP(A2:A5,LAMBDA(x,AND(FILTER(Sheet1!B2:B,Sheet1!A2:A=x))))
TO refer full column as input for large and growing dataset, try-
=MAP(A2:INDEX(A2:A,COUNTA(A2:A)),LAMBDA(x,AND(FILTER(Sheet1!B2:B,Sheet1!A2:A=x))))
答案2
得分: 0
以下是翻译好的部分:
一种处理方法是:
- 使用FILTER函数来收集每个匹配的T/F结果。
- 使用IF语句根据T/F将单元格设置为1或0。
- 使用ARRAYFORMULA函数包装前面的方程,以允许多单元格输出。
- 使用PRODUCT函数,如果所有实例都为TRUE则返回1,如果一个或多个实例为FALSE则返回0。
=PRODUCT(ARRAYFORMULA(IF(FILTER(Sheet1!B2:B9, Sheet1!A2:A9=A2)=TRUE, 1, 0)))
另外,可以将方程包装在另一个IF语句中,以修改输出类型,例如(1,0)、(TRUE,FALSE)、(RED,YELLOW)等。
英文:
One way to approach this is:
-
FILTER to collect the result of every matching T/F
-
IF statement to set the cell to either 1 or 0 depending on the T/F
-
ARRAYFORMULA to wrap the previous equations to allow for multi-cell output
-
PRODUCT to return 1 if all instances are TRUE or 0 if one or more instances are FALSE.
=PRODUCT(ARRAYFORMULA(IF(FILTER(Sheet1!B2:B9, Sheet1!A2:A9=A2)=TRUE, 1, 0)))
Additionally the equation can be wrapped in another IF statement to modify the output type. i.e (1,0), (TRUE,FALSE), (RED,YELLOW), etc.
答案3
得分: 0
这是您要翻译的部分:
尝试:
=AND(QUERY(Sheet1!$A$2:$B$9,"Select B where A = '"&A2&"'"))
拖动下方。
解释:
然后将其包装在AND()
中,如果所有条件都为真则返回TRUE,如果至少有一个为假则返回FALSE。
英文:
Try:
=AND(QUERY(Sheet1!$A$2:$B$9,"Select B where A = '"&A2&"'"))
Drag down below.
Explanation:
Using QUERY()
to get all the data from Column A
You then modify this to only return TRUE or FALSE which is in Column B.
You then add the wrap it with AND()
which will return TRUE if all conditions are true, and FALSE if at least one is false.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论