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?

huangapple go评论67阅读模式
英文:

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公式。

英文:

Example Sheet

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))))

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?

英文:

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))))

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?

答案2

得分: 0

以下是翻译好的部分:

一种处理方法是:

  1. 使用FILTER函数来收集每个匹配的T/F结果。
  2. 使用IF语句根据T/F将单元格设置为1或0。
  3. 使用ARRAYFORMULA函数包装前面的方程,以允许多单元格输出。
  4. 使用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:

  1. FILTER to collect the result of every matching T/F

  2. IF statement to set the cell to either 1 or 0 depending on the T/F

  3. ARRAYFORMULA to wrap the previous equations to allow for multi-cell output

  4. 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&"'"))

拖动下方。

结果:
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?

解释:

使用 QUERY() 从A列获取所有数据
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?

然后将其修改为仅返回TRUE或FALSE,位于B列。
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?

然后将其包装在AND() 中,如果所有条件都为真则返回TRUE,如果至少有一个为假则返回FALSE。

英文:

Try:

=AND(QUERY(Sheet1!$A$2:$B$9,"Select B where A = '"&A2&"'"))

Drag down below.

Result:
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?

Explanation:

Using QUERY() to get all the data from Column A
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?

You then modify this to only return TRUE or FALSE which is in Column B.
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?

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.

huangapple
  • 本文由 发表于 2023年6月6日 08:33:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76410747.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定