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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Yonah
Helper II
Helper II

Find a Word in a Text Column based on another Table

Hi,
I'm trying to find a Word in a Column based on a Column from another Table.

So, my Table A is like:

Values to be searched
Chair Toro
Chair Tammy
Chair Dayton
Chair Thor
Office chair Thor
Office chair Toro

Office chair Dayton

 

 

My Table B how contains a List of Names locks like this:

Value to search forValue to search for
DaytonDayton
TammyTammy
VancouverVancouver
ThorThor
  


And so on.


Now I try to find for Example the Word Tammy in Table A using this custom coulum:
let myvalue=[Values to be searched]
in
Text.Combine(
Table.SelectRows(TableB,
each Text.Contains(myvalue,[Value to search for]))[Corresponding value]
,
",")

 

 

 

The Result I am getting is the following:

Values to be searchedResult
Chair ToroTor,st,ro,,To
Chair Tammyam,Tam,le,Ta,tl,stl,Tamm,,Tammy
Chair DaytonDayton,ro,,Da,Day
Chair Thorho,ro,,Thor
Office chair Thorho,ro,,Thor
Office chair ToroTor,st,ro,,To

Office chair Dayton

Dayton,ro,,Da,Day

 

So, the problem is, my way is not only locking for the entire word, but also for parts of it and therefore even if the world is not in Table B I still get some findings.

My question is, is there a way to make sure that my formula is only locking at the entire word and not just part of it?

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Code for Table A - See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs5IzCxSCMkvylcISczNrVQIycgvUorVgcuABJH4LomVJfl5yApg6v3T0jKTUxWS8YkCrcEQPbQAZmYsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Values to be searched" = _t]),
    BuffList = List.Buffer(#"Table B"[Value to search for]),
    #"Added Custom" = Table.AddColumn(Source, "Result", each Text.Combine(List.RemoveNulls(List.Transform(Text.Split([Values to be searched]," "), (x)=>if List.Contains(BuffList,x) then x else null)),", "))
in
    #"Added Custom"

 Test code for Table B, if you need

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckmsLMnPU4rViVYKSczNrQSzwhLzkvNLy1KLIOIZ+UBGLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Value to search for" = _t])
in
    Source

View solution in original post

3 REPLIES 3
Vijay_A_Verma
Super User
Super User

Code for Table A - See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wcs5IzCxSCMkvylcISczNrVQIycgvUorVgcuABJH4LomVJfl5yApg6v3T0jKTUxWS8YkCrcEQPbQAZmYsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Values to be searched" = _t]),
    BuffList = List.Buffer(#"Table B"[Value to search for]),
    #"Added Custom" = Table.AddColumn(Source, "Result", each Text.Combine(List.RemoveNulls(List.Transform(Text.Split([Values to be searched]," "), (x)=>if List.Contains(BuffList,x) then x else null)),", "))
in
    #"Added Custom"

 Test code for Table B, if you need

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckmsLMnPU4rViVYKSczNrQSzwhLzkvNLy1KLIOIZ+UBGLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Value to search for" = _t])
in
    Source

First of all, Thank you for your Soulotion.
Unfontiontly its not working for my complet Dataset.
When aplying your Soclution. 
I get the Error: Expression.Error: We cannot convert a value of type List to type Table.

My M-Code is:

Where only the last two comands are important.





#"Umbenannte Spalten2" = Table.RenameColumns(#"Entfernte Spalten2",{{"Bezeichnung", "Values to be searched"}}),
BuffList = List.Buffer(#"Table B"[Value to search for]),
#"Hinzugefügte benutzerdefinierte Spalte1" = Table.AddColumn(BuffList, "Benutzerdefiniert", each Text.Combine(List.RemoveNulls(List.Transform(Text.Split([Values to be searched]," "), (x)=>if List.Contains(BuffList,x) then x else null)),", "))
in
#"Hinzugefügte benutzerdefinierte Spalte1"

Replace this portion Table.AddColumn(BuffList

with

Table.AddColumn(#"Umbenannte Spalten2"

Basically, this step has to refer to previous step which refers to a table. When you put Bufflist, it referred to a list not to a table. 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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