'How to match the most approximate values of one column with the string column in another table in Power Query of Power BI?

Table 1:

enter image description here

Table 2:

enter image description here

Result:

enter image description here

I have tried using Fuzzy matching but it's not giving me the results.

Please help!



Solution 1:[1]

See if this works for you in powerquery

Code for Table1, after having created Table2:

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
RelativeMerge = Table.AddColumn(Source, "RelativeJoin", 
        (x) => Text.Combine(Table.SelectRows(Table2, each Text.Contains(x[Column1],[Column1], Comparer.OrdinalIgnoreCase))[Column1],"::")),
y=List.Transform({1 .. List.Max(List.Transform(RelativeMerge[RelativeJoin], each List.Count(Text.Split(_,"::"))))}, each "match_"& Text.From(_)),
#"Split Column" = Table.SplitColumn(RelativeMerge, "RelativeJoin", Splitter.SplitTextByDelimiter("::", QuoteStyle.Csv), y)
in #"Split Column"

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1