Forum Discussion
Find /compare text string segment between two tables
- 2 years ago
Thanks technosmith 🙂
I have attached a small PBIX with one approach.
Here is an extract of code for Table 1 with the Code column added:
let // ... Earlier steps here // Next step finds first matching Code from Table 2 #"Added Code" = Table.AddColumn(#"Changed Type", "Code", each let CurrentCodeGroup = [CodeGroup] in List.First(List.Select(#"Table 2"[Code],each Text.Contains(CurrentCodeGroup,_))), type text) in #"Added Code"The Added Code step finds the first Code from Table 2 that is contained in the CodeGroup string.
A null value should be returned in the case of no match.
Regards
Hi technosmith
What do you want in the new column in the case of multiple matches? Concatenate them in some way? Or can we assume that will never happen?
Regards
Thanks for responding Owen,
That should never happen.
There should always only be one hit in the "CodeGroup"
- OwenAuger2 years agoSuper User
Thanks technosmith 🙂
I have attached a small PBIX with one approach.
Here is an extract of code for Table 1 with the Code column added:
let // ... Earlier steps here // Next step finds first matching Code from Table 2 #"Added Code" = Table.AddColumn(#"Changed Type", "Code", each let CurrentCodeGroup = [CodeGroup] in List.First(List.Select(#"Table 2"[Code],each Text.Contains(CurrentCodeGroup,_))), type text) in #"Added Code"The Added Code step finds the first Code from Table 2 that is contained in the CodeGroup string.
A null value should be returned in the case of no match.
Regards