Forum Discussion

Salle's avatar
Salle
Icon for Advocate I rankAdvocate I
3 years ago
Solved

Modify "Text.contain" in Power Query to look and identify exact string of text

Background:

I want to create a new table column in power query.

Every time the exact word "abc" is found in [TITLE], abc shall be written in the new Column otherwise N/A.
Column
abc
abc
N/A
...

Code

= Table.AddColumn(#"Summary", "Column", each if Text.Contains([TITLE], "abc") then "abc" else "N/A"


Problem

However with the above function I also get a true value for all word containing abc, for example abcd, aabc etc.

Is there a way in Power Query to look for the exact word and spelling? Similar to the DAX function CONTAINSSTRINGEXACT

 

Thanks in advance.

  • Use this

    if List.Contains(Text.Split([TITLE]," "), "abc") then "abc" else "N/A"

2 Replies

  • Vijay_A_Verma's avatar
    Vijay_A_Verma
    Icon for Most Valuable Professional rankMost Valuable Professional

    Use this

    if List.Contains(Text.Split([TITLE]," "), "abc") then "abc" else "N/A"

    • Salle's avatar
      Salle
      Icon for Advocate I rankAdvocate I

      Thank you! Seems to be working as expected.