Google 工作表中的 COUNTIF 具有多个 'not' 或 'else' 比 Google 表单响应的条件

COUNTIF in Google Sheets with multiple 'not' or 'else' than conditions for responses from Google Forms

我想统计 Google 表格中记录的 2 个问题的 'other' 回复数量 Google Sheet。

Google 表格中的 2 个问题用于在多个答案之间进行选择或在文本中写下一些 'other' 回复,例如:

所以我需要计算在 'other' 位置注册的所有 'other' 类型的设备。

我尝试了不同的方法来记下公式(countif、counta、query 等),但结果却给了我一个 1,而它应该给我一个零。我也尝试简化公式为 'Site A' 编写 'other' 类型的设备,但奇怪的是答案仍然是 1。

我将与以下答案分开:

这些已回答的公式非常适用于计算所有 'other' 个位置的所有 'other' 设备,但对于特定位置仍然给我一个“1”的响应。

我认为问题是我正在混合 2 queries/formulas 但我没有让它们与我需要的 'and' 一起工作,或者如果值为 0 那么它给出我一个 1.

这是我尝试用 'other' 类型的设备隔离 1 个位置,它以某种方式给出了 '1' 响应(我尝试了 '<>PC1' 类型的差异:

=COUNTA(QUERY(datos_equipos!$J2:$J,"Site A", datos_equipos!$B:$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))  

这些是我计算两个 'other' 响应的尝试'

在尝试 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:$B, "where B <> 'PC 1)' 
     and B <> 'PC 2'
     and B <> 'Laptop 1'
     and B <> 'Laptop 2)'", 0)})

尝试 B 与 A 相同,但 'different than' <> 在 '' 内:


=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:$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:$B, "<>PC 1", 
                    datos_equipos!$B:$B, "<>PC 2", 
                    datos_equipos!$B:$B, "<>Laptop 1",
                    datos_equipos!$B:$B, "<>Laptop 2",
                    datos_equipos!$B:$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:$B, "where B '<>PC 1'" )
              & query (datos_equipos!$B:$B, "where B 'PC 2'")
              & query (datos_equipos!$B:$B, "where B '<>Laptop 1'")
              & query (datos_equipos!$B:$B, "where B '<>Laptop 2'")
              , 0}) 

总之:

在GoogleSheet秒,我需要在'other'个位置注册的'other'个设备的数量。两者都是用户提供的字段,而不是给定的可选答案。

我为它做了一个测试文档。到目前为止,单元格 N6-I6 中 sheet 'repo_equipos_global' 中的尝试 D 效果最好。只要有匹配的数据,假设原始数据来自一个不成问题的表格。 [ Link ] (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))))

cell C3(如果不区分site 1site1 个州):

=COUNTIFS(datos_equipos!$B:$B, $A3, datos_equipos!$J:$J, C)+
 COUNTIFS(datos_equipos!$B:$B, $A3, datos_equipos!$J:$J, SUBSTITUTE(C, " ", ""))

demo spreadsheet