We help IT Professionals succeed at work.

Excel formula - count how many times a word appears in a list split down by corresponding field

84 Views
Last Modified: 2019-03-08
Hi

I need a formula to to count how many times a word or phase appears in a list, Please note the word or phrase can come in any part of the cell (i.e. have other text before or after it).  
The results need to be broken down by details in a corresponding field (in this instance Gender). the attached spreadsheet has a some sample data and also the output from that sample which I hope helps.  Also embedded below is an image of the data.

Example of data
Can anyone help?
EE-Example.xlsx
Comment
Watch Question

Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
I would strongly recommend adjusting the data into a single value of STAT per row, either at the source before it gets in to Excel, or as a first step in the process in Excel (a macro could be created to break it apart).

Once you have the data in that format with one STAT per row, then the result you are after becomes a very simple pivot table, something that Excel is great at.  Attached is an example of what I mean, hope this helps.

EE-Example.xlsx


»bp

Author

Commented:
Hi Bill,

Thanks for that, normally I would, but there's a lot of different questions to analyse & it would take me ages to break then out.  I did however manage to find Sum Countifs which seems to do the job if I put a wild card in before & after the phrase ...

=SUM(COUNTIFS(UK!$F:$F,"*"&$A16&"*",UK!$B:$B,B$2))

Just checking that through to make sure it fully works
Finance Analyst
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Bill PrewTest your restores, not your backups...
CERTIFIED EXPERT
Expert of the Year 2019
Top Expert 2016

Commented:
Ah, I wasn't thinking you would already know all the possible "categories" that could show up in the STAT column.

One thing to keep in mind, that only works well if none of the STAT categories are ever substrings of each other.  For example, if you had:

People
People Skills

Then you could get some double counting.  As it stands not a problem from your example, just something to keep in mind.


»bp
Hakan YılmazProject Controls Lead Engineer
CERTIFIED EXPERT

Commented:
You may try something like this. I attached file with minor differences. This takes into account the possibility of substrings.
=SUMPRODUCT(--($A$3:$A$9=E$2);--ISNUMBER(FIND(", "&$D3&",";", "&$B$3:$B$9&",")))

Open in new window

EE-Example.xlsx

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions