Count cells containing specific text using Pivot without helper columns

tiro

New Member
Joined
Aug 12, 2021
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
Hi guys,
Long time lurker, first time poster here.

I'm working with results from a SharePoint survey that allows the respondent to check multiple boxes for a single question. In Excel, such answers are concatenated in a single cell with delimiters. For example, one answer could be
Apple;#Orange;#Banana
and another
Apple;#Banana

I need to count the number of times a certain word (eg Banana) occurs in a column with such concatenated values. It's very similar to this use case:


I would like to do this with a pivot table, but without using helper coloumns in the source data.

Is this in any way possible? I'm fine using VBA, and could also possibly get PowerPivot if needed - but would like to avoid it.

Thanks in advance!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Something like this?
Book1
ABCDEFGHIJK
1Survey ResultsRow LabelsCount of Survey ResultsFruitVotes
2AppleApple2Apple6
3Banana,#Apple,#OrangeApple,#Orange2Orange9
4Apple,#OrangeBanana,#Apple,#Orange2Banana6
5Orange,#BananaOrange,#Banana3Pineapple1
6Pineapple,#Banana,#OrangePineapple,#Banana,#Orange1
7Banana,#Apple,#OrangeOrange1
8AppleBanana,#pinepple1
9Orange,#BananaGrand Total12
10Apple,#Orange
11Orange,#Banana
12Orange
13Banana,#pinepple
14
15
Sheet1
Cell Formulas
RangeFormula
J2:J5J2=SUMPRODUCT((ISNUMBER(FIND(I2,$E$2:$E$7))*1),$F$2:$F$7)
 
Upvote 0
Thanks, This works, but I need to count the cells using pivot, so that it's easier to filter the data before doing the count. Any way to count using pivot?
 
Upvote 0
Thanks, This works, but I need to count the cells using pivot, so that it's easier to filter the data before doing the count. Any way to count using pivot?
Sorry, was on mobile, didn't see your whole screenshot at first. This might actually work, thanks! :) Unless there is some way to solve it completely within the pivot?
 
Upvote 0
Then I would make life simple and split the text per delimiter in new rows via PowerQuery. Then simply group by per lemma.
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Survey"]}[Content],
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(Source, {{"Survey Results", Splitter.SplitTextByDelimiter(",#", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Survey Results"),
    #"Grouped Rows" = Table.Group(#"Split Column by Delimiter", {"Survey Results"}, {{"Count", each Table.RowCount(_), Int64.Type}})
in
    #"Grouped Rows"
The green table would be the result.
Book1
ABCDEFGHIJK
1Survey ResultsRow LabelsCount of Survey ResultsFruitVotes
2AppleApple2Apple6
3Banana,#Apple,#OrangeApple,#Orange2Orange9
4Apple,#OrangeBanana,#Apple,#Orange2Banana6
5Orange,#BananaOrange,#Banana3Pineapple1
6Pineapple,#Banana,#OrangePineapple,#Banana,#Orange1
7Banana,#Apple,#OrangeOrange1
8AppleBanana,#pinepple1Survey ResultsCount
9Orange,#BananaGrand Total12Apple6
10Apple,#OrangeBanana7
11Orange,#BananaOrange9
12OrangePineapple1
13Banana,#pinepplepinepple1
14
Sheet1
Cell Formulas
RangeFormula
J2:J5J2=SUMPRODUCT((ISNUMBER(FIND(I2,$E$2:$E$7))*1),$F$2:$F$7)
 
Upvote 0
Solution
Didn't have a chance to test this until today, but just wanted to let you know that your solution worked flawlessly. Thanks so much!
 
Upvote 0
Hi @tiro, feedback and mark as solution are appreciated! Which one of the solutions did you finally go for?
 
Upvote 0
Hi @tiro, feedback and mark as solution are appreciated! Which one of the solutions did you finally go for?
I used the Power Query solution for now, so I marked that as the solution. However, I think I will also use your first proposed solution at a later point, to allow for easy use of pivot slicers, etc!
 
Upvote 0
Obviously, was fooled by my own post where I kept all solutions in one screenshot. :rolleyes:
Slicers work on tables too. But I reckon you have more columns in the real situation. Remember you can feed the PQ to a pivot table too. So you sum the count in the end.
 
Upvote 0

Forum statistics

Threads
1,215,661
Messages
6,126,091
Members
449,290
Latest member
mrsbean

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top