cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
morgtd30
Helper I
Helper I

Count records that contain text from each row

I'd like to get a count of the amount of times different strings show up in another table.

 

Table of search values:

ID    Text
1     Apple

2     Banana

3     Grapes

4     Orange

 

Table of data:

JohnApple, Banana
HenryApple, Banana
JakeOrange
JenniferApple
JackieGrapes, Orange
MikeApple, Grapes

 

How do I have the first table count this as the end result?:

ID    Text        Count
1     Apple         4

2     Banana       2

3     Grapes        2

4     Orange       2

 

1 ACCEPTED SOLUTION
morgtd30
Helper I
Helper I

I achieved it with this calculated column:
Countif = COUNTX(
FILTER(Customers,CONTAINSSTRING(Customers[purchases],'Produce'[text)),1)
 
Now I'd love to be able to filter by the produce types but that's a different problem.

View solution in original post

3 REPLIES 3
HotChilli
Super User
Super User

For the full solution (involving filtering) you could split the column by delimiter, -> To Rows

then create a relationship using the first table as a dimension table

morgtd30
Helper I
Helper I

I achieved it with this calculated column:
Countif = COUNTX(
FILTER(Customers,CONTAINSSTRING(Customers[purchases],'Produce'[text)),1)
 
Now I'd love to be able to filter by the produce types but that's a different problem.
AbbasG
Memorable Member
Memorable Member

@morgtd30 there is no primary key between the two tables, how do you connect them?

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors