Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
KCfromDC
Frequent Visitor

Counting the number of occurrences of a string in different columns

Hi all-

I've gone around in circles trying to get this to work and am at my wit's end. I'm sure it's an easy solution, but I'm still learning PoweBI and none of my searches have come up with an answer.

 

I have a table coming from a system where the user can add up to three tags to a record. Unfortunately, all of the tags get combined into one column, and they're not in alphabetical order. Fortunately, they are delimited by a comma, so I was able to split them across three columns:

 

A.1A.2A.3
AppleBananaCarrot
AppleCarrot 
BananaAppleCarrot
Carrot  
BananaCarrotApple
CarrotBanana 

 

I've been trying to count the total number of occurences of each tag in the table as a measure. (E.g., total # of "Apple" = 4, Bananas = 4, Carrot = 5).

 

Unfortunately, using a filter causes the other two columns to not be counted - for example, column A.1 filtered to "Apple" will not count the occurrences in rows #3 and #5 (columns A.2 and A.3, respectively) as it can't "see" them.

 

I've tried using the following to clear the filter, but it still only counts what's in the first column.

 

 

 

 

AppleCount = CALCULATE(
COUNROWS(FILTER(Table,[A.1]="Apples"))) +
CALCULATE(
COUNTROWS(FILTER(ALL(Table),Table[A.2]="Apples")))

 

 

 

 

 

Any help is much appreciated. Thank you!

 

1 ACCEPTED SOLUTION
smpa01
Super User
Super User

@KCfromDC  I answered a similar question Here 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @KCfromDC,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

smpa01
Super User
Super User

@KCfromDC  I answered a similar question Here 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
KCfromDC
Frequent Visitor

Hi all-

Thank you - not sure if this will work, though, as it's a 3,000+ row dataset with 10 columns. I wanted to use the above as a simpler example, so unpivoting them may not work... 😕

NidhiBhusari
Helper IV
Helper IV

Hi @KCfromDC ,

Go to power Query and unpivot the columns then add conditional column to assign ID to the tags. AFter following these steps you will get below table.

NidhiBhusari_0-1638257684789.png


Then drag ID's column(Take count of it) in Table visual.

NidhiBhusari_1-1638257813675.png

 

amitchandak
Super User
Super User

@KCfromDC , When you split them , you can split rows, in this case that would be a better option

Split Column Power Query: https://youtu.be/FyO9Vmhcfag

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.