我想统计 Google 表格中记录的 Google 表单中 2 个问题的“其他”回复数量。
Google 表单中的 2 个问题用于在多个答案之间进行选择或以文本形式写下一些“其他”答案,例如:
- 问题 1 是“地点”(地点 A、地点 B、地点 C、地点 D、其他)
- 问题 2 是“设备类型”(PC 1、PC 2、笔记本电脑 1、笔记本电脑 2、其他)
所以我需要计算在“其他”位置注册的所有“其他”类型的设备。
我尝试了不同的方法来写下公式(countif、counta、query 等),但结果却给了我 1,而它应该给我一个零。我还尝试简化公式,为“站点 A”编写“其他”类型的设备,但奇怪的是,答案仍然是 1。
我不同意以下答案: Countifs in Google Sheets with various 'different than' criteria in same row adds +1 value
这些答案公式对于所有“其他”位置的所有“其他”设备的计数非常有效,但对于特定位置仍然给出“1”的响应。
我认为问题是我混合了 2 个查询/公式,但我没有按照我的要求让它们与“and”一起工作,或者如果值为 0,那么它会给我一个 1。
这是我尝试将 1 个位置与“其他”类型的设备隔离,它以某种方式给出“1”响应(我尝试了与“<>PC1”类型的差异:
=COUNTA(QUERY(datos_equipos!$J2:$J,"Site A", datos_equipos!$B$2:$B,
"where not B contains 'PC 1'
and not B contains 'PC 2'
and not B contains 'Laptop 1'
and not B contains 'Laptop 2'
", 0))
这些是我对“其他”回复进行计数的尝试
在尝试 A 中,我尝试进行 2 个查询:
=COUNTA({QUERY(datos_equipos!$J2:$J, "where J <> 'Site A' and J <> 'Site B' and J <> 'Site C' and J <> 'Site D'")
& query (datos_equipos!$B$2:$B, "where B <> 'PC 1)'
and B <> 'PC 2'
and B <> 'Laptop 1'
and B <> 'Laptop 2)'", 0)})
尝试 B 与 A 相同,但“不同于”<> 位于“”内:
=COUNTA({QUERY(datos_equipos!$J2:$J, "where J '<>Site A' and J '<>Site B' and J '<>Site C' and J '<>Site D'")
& query (datos_equipos!$B$2:$B, "where B '<>PC 1'
and B '<>PC 2'
and B '<>Laptop 1'
and B '<>Laptop 2'", 0)})
尝试 C 尝试在调用每个选项并尝试排除空白单元格时进行直接计数:
=countifs(datos_equipos!$J2:$J, "<>Site A",
datos_equipos!$J2:$J, "<>Site B",
datos_equipos!$J2:$J, "<>Site C",
datos_equipos!$J2:$J, "<>Site D",
datos_equipos!$B$2:$B, "<>PC 1",
datos_equipos!$B$2:$B, "<>PC 2",
datos_equipos!$B$2:$B, "<>Laptop 1",
datos_equipos!$B$2:$B, "<>Laptop 2",
datos_equipos!$B$2:$B,"<>"
)
最后,尝试D.,在本例中,答案是2。这里我尝试查询每个选项:
=COUNTA({QUERY(datos_equipos!$J2:$J, "where J '<>Site A'")
& query (datos_equipos!$J2:$J, "where J '<>Site B'")
& query (datos_equipos!$J2:$J, "where J '<>Site C'")
& query (datos_equipos!$J2:$J, "where J '<>Site D'")
& query (datos_equipos!$B$2:$B, "where B '<>PC 1'" )
& query (datos_equipos!$B$2:$B, "where B 'PC 2'")
& query (datos_equipos!$B$2:$B, "where B '<>Laptop 1'")
& query (datos_equipos!$B$2:$B, "where B '<>Laptop 2'")
, 0})
总而言之:
在 Google 表格中,我需要在“其他”地点注册的“其他”设备的数量。两者都是用户提供的字段,而不是给定的可选答案。
我为它制作了一个测试文档。到目前为止,单元格 N6-I6 中工作表“repo_equipos_global”中的尝试 D 效果最好。只要有匹配的数据,考虑到原始数据来自表格,就不应该有问题。 [链接](https://docs.google.com/spreadsheets/d/1hnKw6LjG3Vv6-1Yg60RzzXnsh6uzFKYqyu1D36EA1jQ/edit?usp=sharing)
最佳答案
细胞C8:
=ARRAYFORMULA(COUNTA(IFERROR(QUERY(QUERY(
LOWER({datos_equipos!B2:B, datos_equipos!J2:J}),
"where Col2 contains '"&LOWER(C2)&"'
or Col2 contains 'site1'", 0),
"select Col1
where not Col1 contains 'PC 1'
and not Col1 contains 'PC 2'
and not Col1 contains 'PC 3'
and not Col1 contains 'Laptop 1'
and not Col1 contains 'Laptop 2'", 0))))
单元格F8:
=ARRAYFORMULA(COUNTA(IFERROR(QUERY(QUERY(
LOWER({datos_equipos!B2:B, datos_equipos!J2:J}),
"where not Col2 contains 'site1'
and not Col2 contains 'site2'
and not Col2 contains 'site3'
and not Col2 contains 'site 1'
and not Col2 contains 'site 2'
and not Col2 contains 'site 3'", 0),
"select Col1
where not Col1 contains 'PC 1'
and not Col1 contains 'PC 2'
and not Col1 contains 'PC 3'
and not Col1 contains 'Laptop 1'
and not Col1 contains 'Laptop 2'", 0))))
单元格C3(如果您不区分site 1
和site1
> 州):
=COUNTIFS(datos_equipos!$B:$B, $A3, datos_equipos!$J:$J, C$2)+
COUNTIFS(datos_equipos!$B:$B, $A3, datos_equipos!$J:$J, SUBSTITUTE(C$2, " ", ""))
demo spreadsheet
关于google-sheets - Google 表格中的 COUNTIF 多个 'not' 或 'else' 比 Google 表单响应的条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56135657/