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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Community Champion
Community Champion

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])


Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

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])


Follow on LinkedIn
@ 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!:
DAX For Humans

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

Whoa, thank you very much! 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Kudoed Authors