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
OSin
New Member

Count Number of Matches in all rows

Hi All,

 

I have searched for a solution to this question but have had no luck so far.

 

I would like to calculate the number of string occurences in all rows of a certain column, based on a string in the current row of a seperate column. For example:

 

BOM
COMPONENT2,COMPONENT3,COMPONENT3
COMPONENT1,COMPONENT5,COMPONENT3
COMPONENT2,COMPONENT1
COMPONENT1,COMPONENT3
COMPONENT1,COMPOMENT2,COMPONENET3,COMPONENT4

 

SKUSKU in BOM
COMPONENT 14
COMPONENT 23
COMPONENT 35
COMPONENT 41
COMPONENT 51

 

Currently, I can count the rows where the string occurs using DAX:

 

 

SKU in BOM = countrows(filter('Data',find(earlier('Data'[SKU]),'Data'[BOM],,0)>0))

But this gives just a count of the rows, wheras I want to get the total number of occurances.

 

I have seen a suggestion of using Text.Split to get the number of occurences, but I'm not sure how to reference the "SKU" Column as the delimiter and how to iterate over every row and sum, rather than just the current row.

 

Edit: The main issue I have is that each component can be present more than once in any given row. Editted the tables to clarify.

 

Any help would be appreciated.

 

1 ACCEPTED SOLUTION

I personally duplicate the table and I open the query Editor to split the data into rows

 

1.png

 

Then I can apply the DAX formula proposed by @Zubair_Muhammad

 

2.png

 

Then you can use this table in a visual rapidly.

 

I know it is only to save you because a DAX formula should solve it but I don't know it !

 

Regards,

CR

 

 

 

 

View solution in original post

12 REPLIES 12

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.