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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
_Kelz0484
Frequent Visitor

DAX Search for exact match within a string of text

Hi,

 

I have 2 columns within the same table and I trying to find a DAX function that uses the value of 1 column to search the other to see if it contains the 1st as an exact match.

 

Column 1 contains a list of fitting numbers.

Column 2 contains a description of the fitting and in some cases the fitting number as well.

 

  • The issue I am having is that the fitting numbers are in groups ie. MW, MW1, MW2 etc etc. I have used EXACT and CONTAINSSTRING but because it finds the MW in multiple instances it tells me there is a match. I only want it to match if complete fitting number is in the description Column.

 

Any help would be appreciated.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @_Kelz0484 

 

Please try this m code:

let a = List.Contains(Text.Split([Description]," "),[Fitting No])
in if a = true then "Exact Match" else "Mismatch"

You can add a custom column in power query:

vzhengdxumsft_0-1722323558845.png

Then paste the code in it:

vzhengdxumsft_1-1722323590650.png

The result is as follow:

vzhengdxumsft_5-1722323892190.png

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @_Kelz0484 

 

Please try this m code:

let a = List.Contains(Text.Split([Description]," "),[Fitting No])
in if a = true then "Exact Match" else "Mismatch"

You can add a custom column in power query:

vzhengdxumsft_0-1722323558845.png

Then paste the code in it:

vzhengdxumsft_1-1722323590650.png

The result is as follow:

vzhengdxumsft_5-1722323892190.png

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Greg_Deckler
Community Champion
Community Champion

@_Kelz0484 Can you provide some sample data posted as text to test with?



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...

Hi @_Kelz0484 

 

Would a column llike this help?

Result = 
    IF(
        LEN( [Fitting No] ) = 0,
        "Mismatch",
        IF(
            CONTAINSSTRINGEXACT(
                [Description],
                [Fitting No]
            ),
            "Exact Match",
            "Mismatch"
        )
    )

 

_Kelz0484.pbix

 

 



Proud to be a Super User!

daxformatter.com makes life EASIER!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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