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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.