Using COUNTIF in numbers to count cells that contain specific text but not only that text

Hello


I am using COUNTIF to count cells in a table that contain specific text. This is fine. I can do this as long as the text is an exact match. What I need is an additional bit of formula to make it return a count when the cell contains that text, even if there is further text in the cell.


For instance: Cells contain values such as "Activity: Taekwondo", "Activity: Music", "Activity: Art" etc


I am using the formula COUNTIF(data, "Activity") but it is not designed to return a count as there is further text.


Can anyone help?


Thank you

Emily

MacBook Pro 13", macOS 10.13

Posted on Feb 26, 2020 7:56 AM

Reply
Question marked as Top-ranking reply

Posted on Feb 26, 2020 4:29 PM

Emily, Numbers allows you to use the “wildcard” * in COUNTIF.


So if you want to count the number of cells that contain “activity” then you simply can do something like:


=COUNTIF(data,”*activity*”)


SG

7 replies

Feb 26, 2020 4:48 PM in response to Emisdamum

Further notes (adding separately as the forum software timed out):


If you want to count only cells with values that start with “activity” then you can use “activity*”.


If you want to count only cells with values that contain “activity” somewhere other than the beginning then you can use “*activity”.


The match is not case-sensitive. Whether you use activity or Activity the results will be the same.


SG

Feb 26, 2020 9:45 AM in response to Emisdamum

it will be easiest to create a set of columns that identify a particular string is found in the column of activities. The extra columns can identify that a particular string exists in the first string by using the following:



assuming the list of strings is in column A

and the extra columns are in column B thru D (assuming we are only looking for "Taekwondo", "Music", "Art")


the extra columns will indicate the presence of one of the words in the phrase does (or does not exist) by doing the following:

put the word (or phrase) you want to find in row 1.

make row 1 a header row


e.g. cell B1 contains "Taekwondo"

cell C1 contains "Music"

D1 contains "Art"


then select cell B2 and type (or copy and paste from her) the formula:

=IF(SUBSTITUTE($A2, B$1, "",occurrence)<>$A2, 1, 0)


shorthand for this is:

B2=IF(SUBSTITUTE($A2, B$1, "",occurrence)<>$A2, 1, 0)



select cell B2, copy

select cells B2 thru D8, paste


after you get this working, add a second header row:

and add the formula

B2=SUM(B)

select cell B2 copy

select cells B2 thru D2, paste





Feb 27, 2020 12:06 PM in response to SGIII

"If you want to count only cells with values that contain “activity” somewhere other than the beginning then you can use “*activity”.


Actually, "*activity" will count only cells with values that end with "activity", including those that contain only "activity"


Here's an example with the 'full set'. Each cell in columns B-F has the formula shown below the table, with the search string edited to match the label at the top of its column. The 'range' in each case is the single cell on the same row of column A as the formula.


The "*" wild card will accept 'any number of characters, including none'.

Column F uses the 'other' wild card, "?", which accepts (and requires) only 'a single character'. To count "practice" using ?, the search string "??act*" or "??act???" could be used.


Regards,

Barry

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Using COUNTIF in numbers to count cells that contain specific text but not only that text

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.