Counting Comma Separated string in cells in a Column

Hi all,


Trying to move some of my Excel sheets to Numbers. I would appreciate some help counting a specific text/number string in cells in a column. In the example below (not the full works sheet) is a column the work packs (WP01, WP02, and so on) - This signifies which work packs a particular Test & Validation (e.g. TV-102) document is applicable to.


I would like to be able to simple count the number of occurrences, say "WP05", is applicable. If I use COUNTIF, on the "WorkPack" column, it only counts those cells that contain only the string "WP05" (i.e. in the sheet I am working with, I know there are 22 entries for "WP05" in the work pack column, but only counts 14)


Note: I am building this on my MAC, but would like to be able to access and use these sheets on my iPad - Not sure if this makes a difference.


Any suggestions / ideas ?


Thank you in advance ...


ATB Perry


id

Document Group

WorkPack

TV-91

NFR Validation

WP05, WP06

TV-102

Certificate of Compliance

WP05, WP06

TV-103

NFR Validation

WP05, WP06

TV-206

FR Test

WP05

TV-207

FR Test

WP05

TV-208

FR Test

WP05

TV-209

FR Test

WP05

TV-212

Certificate of Compliance

WP01, WP02, WP03, WP04, WP05, WP06, WP07, WP08, WP09, WP10, WP11, WP12, WP13, WP14, WP15

TV-213

NFR Validation

WP01, WP02, WP03, WP04, WP05, WP06, WP07, WP08, WP09, WP10, WP11, WP12, WP13, WP14, WP15

TV-214

FR Test

WP01, WP02, WP03, WP04, WP05, WP06, WP07, WP08, WP09, WP10, WP11, WP12, WP13, WP14, WP15

TV-215

NFR Validation

WP01, WP02, WP03, WP04, WP05, WP06, WP07, WP08, WP09, WP10

TV-308

NFR Validation

WP01, WP02, WP03, WP04, WP05, WP06, WP07, WP08, WP09, WP10, WP11, WP12, WP13, WP14, WP15

TV-338

FR Test

WP05

MacBook Pro, Mac OS X (10.7.5)

Posted on Jul 30, 2016 6:50 AM

Reply
14 replies

Jul 30, 2016 8:33 AM in response to PASEL

Here is how I would approach this (without more information):

User uploaded file


add additional columns to your table (the ones titled "WP01", "WP02", etc). enter the names as shown

The first row is a header row.


Also... add one extra row at the end and make it a footer row


D2=(LEN($C2)−LEN(SUBSTITUTE($C2, D$1, "")))÷LEN(D$1)


this is shorthand for... select cell D2, then type e(or copy and paste from here) the formula:

=(LEN($C2)−LEN(SUBSTITUTE($C2, D$1, "")))÷LEN(D$1)


select cell D2, copy

select cells D2 the the end of column R, paste

in the footer row (row 15 of this example) iff the following formula:

D15=sum(D)

select cell D15, copy

select cells D15 thru R15, paste


I could never locate 22 occurrences of WP05 (even when I search your post on this web page):

User uploaded file

Jul 30, 2016 8:36 AM in response to PASEL

Hi Pasel,

Here is one approach. Insert another table ('FIND start position') and use the FIND function to find the starting position of a WorkPack in each row of the Data table.

Wrap this in IFERROR to return zero if a WorkPack does not exist in that row of the Data table.

User uploaded file

Formula in B2 (and Fill Right and Fill Down)

=IFERROR(FIND(B$1,Data::$C2),0)


The table on the right ('FIND start position') has a Header Row and a Footer Row.

Formula in Footer Cell B16 (and Fill Right)

=COUNTIF(B,">0")

User uploaded file


Regards,

Ian.

Jul 30, 2016 10:05 AM in response to Wayne Contello

Hi Wayne,


Yes, it is mentioned.

http://help.apple.com/functions/mac/5.0/#/ffa5b9f72f


"The wildcards you can use are ? (question mark), * (asterisk), and ~ (tilde). To find more information about wildcards, open the Help menu in your app and enter “wildcard” in the search field."


According to the help "Functions that accept conditions and wildcards as arguments", wildcards can be used for following functions. ( checked with Numbers for Mac ver. 3.6.2 )

  • AVERAGEIF
  • AVERAGEIFS
  • COUNTIF
  • COUNTIFS
  • SUMIF
  • SUMIFS
  • SEARCH

Jul 30, 2016 11:32 AM in response to To_Mi

Hi To_Mi,


Thank you for restoring my faith - I actually did try to use a wildcard, but kept getting the annoying Red Error triangle - Looking at the syntax, I can now see why ... Much cleaner than Excel!


Tried it - Works fine!


Question: Is it possible to add a condition using this wildcard approach - For example, could it be adapted to count all "FR Test" that are applicable to "WP05"?


I forget how I did this in excel, but I remember it was a bit cranky - Slowed my workbook down too.


Thanks again


Perry

Jul 30, 2016 12:37 PM in response to PASEL

Hi Perry,

Question: Is it possible to add a condition using this wildcard approach - For example, could it be adapted to count all "FR Test" that are applicable to "WP05"?

Counting cells that matches multiple conditions can be done with COUNTIFS function.

http://help.apple.com/functions/mac/5.0/#/ffa5a400fc

For the mentioned case, the formula will be :

= COUNTIFS( document-group-column, "FR Test", workpack-column, "*WP05*" )

User uploaded file

note: For the column B of the table below, the formula is the same as my previous post.

Much cleaner than Excel!

I believe the same formula should work on Excel too. ( not tested as I don't have Excel )

https://support.office.com/en-us/article/COUNTIF-function-e0de10c6-f885-4e71-abb 4-1f464816df34

https://support.office.com/en-us/article/COUNTIFS-function-dda3dc6e-f74e-4aee-88 bc-aa8c2a866842

Jul 30, 2016 1:07 PM in response to To_Mi

Hi Wayne,


Sorry, I forgot to list the functions below. They can also use wildcard if exact much is specified with the optional argument.

  • HLOOKUP
  • MATCH
  • VLOOKUP


Link to the page in "Formulas and Functions Help"

http://help.apple.com/functions/mac/5.0/#/ffac131919b - Functions that accept conditions and wildcards as arguments


Note:

FIND is shown in the SG's search result, but the page says.

The search is case sensitive and spaces are counted. Wildcards are not allowed. To use wildcards or to ignore case in your search, use the SEARCH function.

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.

Counting Comma Separated string in cells in a Column

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