Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
678 views
in Technique[技术] by (71.8m points)

if statement - Countifs in Google Sheets with various 'different than' criteria in same row adds +1 value

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...