1
votes

I'm trying to count all values different than some specific criteria on the same row in a Google sheet that is feed via a google form but the final count shows "1".

The row I'm counting from corresponds to a multiple choice question that has an 'other' option so the user can enter other values and I'm trying to count the number of 'other' values in the row.

I tried normal count and couldif but when you use a <> it ends up counting to infinite if you want to check a B2:B range (B1 Is the heading), so I used a structure of this:

=COUNTIFS(query('FORMS RESPONSES'!B2:B,"<>TYPE A"), 
query('FORMS RESPONSES'!B2:B,"<>TYPE B"),
query('FORMS RESPONSES'!B2:B,"<>TYPE C"),
query('FORMS RESPONSES'!B2:B,"<>TYPE D"),
query('FORMS RESPONSES'!B2:B,"<>TYPE E"),
)

Assuming the feed has 1 response for A, B, C, and none for D, E and 2 other entries with random values, the answer should be = 2, yet it gives me only = 1

I have this:

=COUNTIFS(
query(datos!B2:B,"<>PC Tipo 1 (HP)")
,query(datos!B2:B,"<>PC Tipo 2 (Lenovo)")
,query(datos!B2:B,"<>PC Tipo 3 (Dell)")
,query(datos!B2:B,"<>Laptop Tipo 1 (Lenovo)")
,query(datos!B2:B,"<>Laptop Tipo 2 (Thinkpad)")
,query(datos!B2:B,"<>Tel Cel.")
)

VG:

An sample data entry for B2:B would be:

  • PC Tipo 1 (HP)
  • PC Tipo 2 (Lenovo)
  • PC Tipo 3 (Dell)
  • Laptop Tipo 1 (Lenovo)
  • server HP
  • Projector

So there are 6 total entries with 2 being the 'other' kind that I'm trying to count (server HP and Projector). Yet the result gives me =1

3

3 Answers

0
votes

you are getting 1 as one error counted. do it like this:

=COUNTA(QUERY(datos!B2:B, "where not B contains 'PC Tipo 1 (HP)' 
                             and not B contains 'PC Tipo 2 (Lenovo)'
                             and not B contains 'PC Tipo 3 (Dell)'
                             and not B contains 'Laptop Tipo 1 (Lenovo)'
                             and not B contains 'Laptop Tipo 2 (Thinkpad)'
                             and not B contains 'Tel Cel.'", 0))

0

0
votes

or you can do it like this:

=ARRAYFORMULA(COUNTA(datos!B2:B)-
 SUM(COUNTIF(datos!B2:B, {"PC Tipo 1 (HP)",
                          "PC Tipo 2 (Lenovo)",
                          "PC Tipo 3 (Dell)",
                          "Laptop Tipo 1 (Lenovo)",
                          "Laptop Tipo 2 (Thinkpad)",
                          "Tel Cel."})))

0

0
votes

(I'm complementing the answer only by reposting the answer without the 'T.Y.' that got it deleted')

Both answers work perfectly fine. Which one to use would depend on where you need the result to be. Because I don't need the answer in the first or second row (I have in like c20) I'm going with this version:

=COUNTA(QUERY(datos!B2:B, "where not B contains 'PC Tipo 1 (HP)' 
                         and not B contains 'PC Tipo 2 (Lenovo)'
                         and not B contains 'PC Tipo 3 (Dell)'
                         and not B contains 'Laptop Tipo 1 (Lenovo)'
                         and not B contains 'Laptop Tipo 2 (Thinkpad)'
                         and not B contains 'Tel Cel.'", 0))

The other answer would be more fit if you require to have it in the first row and add it in the heading (if you need it to automatically appear in a list as new responses from the Google form come in. In case anyone needs to know how to do that, I used this:

={"Other responses"; ARRAYFORMULA(IF(LEN(A2:A), 
                (COUNTA(datos_equipos!B2:B)- 
                SUM(COUNTIF(datos_equipos!B2:B, 
                {"Escritorio - PC Tipo 1 (HP)", 
                "Escritorio - PC Tipo 2 (Lenovo)", 
                "Escritorio - PC Tipo 3 (Dell)", 
                "Laptop Tipo 1 (Lenovo)", 
                "Laptop Tipo 2 (Thinkpad)", 
                "Telefono Cel." }))) ,""))}