如何翻译 ARRAYFORMULA 中的 QUERY 公式以自动为每一行填充 QUERY
How to translate QUERY formula in ARRAYFORMULA to automatically populate the QUERY for each row
使用我的查询公式,我想计算 A 列(例如 Apple)中某个字符串的所有重复出现次数,同时检查重复字符串出现的同一行中 B 列是否不为空。根据计数是否大于 0,我想在每一行的 C 列中显示一条消息。
在查询的 WHERE 子句中,我引用了要显示消息的 A 列的行号,如下所示:
…where A = '"&A1&"'…
…where A = '"&A2&"'…
…where A = '"&A3&"'…
…
=IF(IFERROR(QUERY($A:$B;"select COUNT(A) where A = '"&A1&"' and B is not
null LABEL COUNT(A) ''";0)) > 0;"B is not empty for duplicate strings";"B
is empty for duplicate strings").
结果应该是这样的:
+---+---------+---+--------------------------------------+--+
| | A | B | C | |
+---+---------+---+--------------------------------------+--+
| 1 | Apple | 1 | B is not empty for duplicate strings | |
| 2 | Apple | | B is not empty for duplicate strings | |
| 3 | Orange | | B is empty for duplicate strings | |
| 4 | Orange | | B is empty for duplicate strings | |
+---+---------+---+--------------------------------------+--+
我想把这个公式翻译成一个数组公式,然后把它放到表头,这样公式就会自动展开。
到目前为止我尝试过的:
={"YOUR HEADER";ARRAYFORMULA(IF(IFERROR(QUERY($A:$B;"select COUNT(A)
where A = '"&A2&"' and B is not null LABEL COUNT(A) ''";0)) > 0;"B is
not empty for duplicate strings";"B is empty for duplicate strings"))}
这仅适用于第二行,因为我的查询引用了 A2 列。我如何更改检查每一行的公式?
在另一个论坛,我得到了答案。对于任何感兴趣的人:
=ArrayFormula(IF(A2:A="";"";IF(QUERY(ArrayFormula(COUNTIF(QUERY(A2:B;"select A,
count(A) where B is not null group by A label count(A)''");A2:B));"select
Col1")>0;"B is not empty for duplicate strings";"B is empty for duplicate strings")))
使用我的查询公式,我想计算 A 列(例如 Apple)中某个字符串的所有重复出现次数,同时检查重复字符串出现的同一行中 B 列是否不为空。根据计数是否大于 0,我想在每一行的 C 列中显示一条消息。
在查询的 WHERE 子句中,我引用了要显示消息的 A 列的行号,如下所示:
…where A = '"&A1&"'…
…where A = '"&A2&"'…
…where A = '"&A3&"'…
…
=IF(IFERROR(QUERY($A:$B;"select COUNT(A) where A = '"&A1&"' and B is not
null LABEL COUNT(A) ''";0)) > 0;"B is not empty for duplicate strings";"B
is empty for duplicate strings").
结果应该是这样的:
+---+---------+---+--------------------------------------+--+
| | A | B | C | |
+---+---------+---+--------------------------------------+--+
| 1 | Apple | 1 | B is not empty for duplicate strings | |
| 2 | Apple | | B is not empty for duplicate strings | |
| 3 | Orange | | B is empty for duplicate strings | |
| 4 | Orange | | B is empty for duplicate strings | |
+---+---------+---+--------------------------------------+--+
我想把这个公式翻译成一个数组公式,然后把它放到表头,这样公式就会自动展开。
到目前为止我尝试过的:
={"YOUR HEADER";ARRAYFORMULA(IF(IFERROR(QUERY($A:$B;"select COUNT(A)
where A = '"&A2&"' and B is not null LABEL COUNT(A) ''";0)) > 0;"B is
not empty for duplicate strings";"B is empty for duplicate strings"))}
这仅适用于第二行,因为我的查询引用了 A2 列。我如何更改检查每一行的公式?
在另一个论坛,我得到了答案。对于任何感兴趣的人:
=ArrayFormula(IF(A2:A="";"";IF(QUERY(ArrayFormula(COUNTIF(QUERY(A2:B;"select A,
count(A) where B is not null group by A label count(A)''");A2:B));"select
Col1")>0;"B is not empty for duplicate strings";"B is empty for duplicate strings")))