Hi @cmd41par
Difficult to say for sure with only 2 truncated transactions.longDescriptions but - if your product has it - you could do it with function Table.FuzzyJoin/Table.FuzzyNestedJoin
Otherwise, assuming data in Table1 and StrMatch in Table2:
the following will return the 1st match in the StrMatch list:
let
fxMatch = (String as text) =>
List.First(
List.RemoveNulls(
List.Generate(
()=>[i = 0, out = if Text.Contains(String, Categories{i}, Comparer.OrdinalIgnoreCase) then Categories{i} else null],
each [i] < NbOfCategories,
each
[
i = [i] + (if [out] <> null then NbOfCategories else 1),
out = if Text.Contains(String, Categories{i}, Comparer.OrdinalIgnoreCase) then Categories{i} else null
],
each [out]
)
)
),
Source = Table1,
Categories = List.Buffer(Table2[StrMatch]),
NbOfCategories = List.Count(Categories),
Categorized = Table.AddColumn(Source, "Category", each fxMatch([LongDescription]), type text)
in
Categorized
Sample with both options available here