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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ilcaa722
Frequent Visitor

Text.Contains but whole word, not part of word

I am doing a Text.Contains  for the word ace. it find ACE HARD, SKYES ACE which is good.... BUT it also finds matches that contain Palace which is bad

 

whats the best way to test a column contains a specific whole word and not part of a word?  thanks

 

(the text column has multiple words and this is just a short sample)

 

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You could split the text into a list and check if the list contains "ace".

 

Try this as a custom column:

List.Contains(Text.Split(Text.Lower([Column1]), " "), "ace")

 

View solution in original post

9 REPLIES 9
ilcaa722
Frequent Visitor

thanks, i tried ace with variations of spaces, but sometimes its first word,ect... also "ace " picks up Palace Ave

 

ill try Alexis solution and see if its robust acrross many examples.

watkinnc
Super User
Super User

True, @AlexisOlson, let's make it " ace" OR "ace ". After all, a space after ace finds that case.


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

Then you'd get true for both "Palace XYZ" and "XYZ Acetone".

watkinnc
Super User
Super User

In fact, "A space before ace if you do not need space."


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
watkinnc
Super User
Super User

"A space before ace gives palace no place."


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
watkinnc
Super User
Super User

Just look for " ace".

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

@watkinnc  Then you don't get "ACE HARD" but you would get "XYZ ACETONE", right?

AlexisOlson
Super User
Super User

You could split the text into a list and check if the list contains "ace".

 

Try this as a custom column:

List.Contains(Text.Split(Text.Lower([Column1]), " "), "ace")

 

HotChilli
Super User
Super User

spaceacespace?

Couldn't resist that, sorry.

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors