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
Anonymous
Not applicable

Attempting to count number of times strings from one column occur in another

I am trying to use a column of unique values to count the number of times the values appear in another table. My data looks like the following: 

 

The values to be looked up:

 

PN_1.PNG

 

 

The values to be looked up against look like this, where the column I am interested in is the 2nd one, "Post Number." 

 

IDs_1.PNG

 

 

What I hope to acheive here is a to be able to create a table (a visual) where I can see a count of how many times each value appears. The tricky part here is of course that I am not looking for an exact match, just whether or not the value is contained somewhere within the cell. 

 

Example: The value "2200" appears 3 times in the above data set, so I would expect to see "3" returned. 

 

From there I plan to filter based on the 3rd and 4th columns, Active, and Approved on the visual level. 

 

I have tried serveral methods without any luck. Any advice? 

 

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

Perhaps something like:

 

Measure = 
VAR __pn = MAX(Table9[PN])
VAR __pnLength = LEN(__pn)
VAR __table = ALL('Table10')
VAR __table1 = ADDCOLUMNS(__table,"__Count",(LEN([Post Number]) - LEN(SUBSTITUTE([Post Number],__pn,"")))/__pnLength)
RETURN SUMX(__table1,[__Count])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

Perhaps something like:

 

Measure = 
VAR __pn = MAX(Table9[PN])
VAR __pnLength = LEN(__pn)
VAR __table = ALL('Table10')
VAR __table1 = ADDCOLUMNS(__table,"__Count",(LEN([Post Number]) - LEN(SUBSTITUTE([Post Number],__pn,"")))/__pnLength)
RETURN SUMX(__table1,[__Count])

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Whoa, thank you very much! 

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.