Google Spreadsheet, Count IF contains a string

2020-02-26 14:07发布

I have a column like this:

What devices will you be using?

iPad
Kindle & iPad
No Tablet
iPad
iPad & Windows

How do I count the amount of people that said iPad?

This formula does work for exact matches but not if it contains an additional value:

=(COUNTIF(A2:A51,"=iPad")/COUNTA(A2:A51))*1

Any Suggestions?

6条回答
爷、活的狠高调
2楼-- · 2020-02-26 14:14

Try just =COUNTIF(A2:A51,"iPad")

查看更多
闹够了就滚
3楼-- · 2020-02-26 14:16

It will likely have been solved by now, but I ran accross this and figured to give my input

=COUNTIF(a2:a51;"*iPad*")

The important thing is that separating parameters in google docs is using a ; and not a ,

查看更多
小情绪 Triste *
4楼-- · 2020-02-26 14:21

.. in case someone is still looking for the answer.. this worked for me:

    =COUNTIF(a2:a51, "*" & b1 & "*")
查看更多
爷的心禁止访问
5楼-- · 2020-02-26 14:21

Try using wildcards directly in the COUNTIF function :

=(COUNTIF(A2:A51,"=*iPad*")/COUNTA(A2:A51))*1
查看更多
劫难
6楼-- · 2020-02-26 14:21

Wildcards worked for me when the string I was searching for could be entered manually. However, I wanted to store this string in another cell and refer to it. I couldn't figure out how to do this with wildcards so I ended up doing the following:

A1 is the cell containing my search string. B and C are the columns within which I want to count the number of instances of A1, including within strings:

=COUNTIF(ARRAYFORMULA(ISNUMBER(SEARCH(A1, B:C))), TRUE)
查看更多
Bombasti
7楼-- · 2020-02-26 14:32

You should use

=COUNTIF(A2:A51, "*iPad*")/COUNTA(A2:A51)

Additionally, if you wanted to count more than one element, like iPads OR Kindles, you would use

=SUM(COUNTIF(A2:A51, {"*iPad*", "*kindle*"}))/COUNTA(A2:A51)

in the numerator.

查看更多
登录 后发表回答