Forum Discussion
How to merge 2 tables in PowerQuery using substrings?
- 3 years ago
On another site I was given a great solution that I will share here to document.
First add a custom column:
Table.SelectRows(Table2, (x)=> Text.Contains ([Sold items], x[Products], Comparer.OrdinalIgnoreCase) )
Now, expand the column.
The code will be:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Sold items", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.SelectRows(Table2, (x)=> Text.Contains ([Sold items], x[Products], Comparer.OrdinalIgnoreCase) )),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Products"}, {"Products"})
in
#"Expanded Custom"
On another site I was given a great solution that I will share here to document.
First add a custom column:
Table.SelectRows(Table2, (x)=> Text.Contains ([Sold items], x[Products], Comparer.OrdinalIgnoreCase) )
Now, expand the column.
The code will be:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Sold items", type text}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Table.SelectRows(Table2, (x)=> Text.Contains ([Sold items], x[Products], Comparer.OrdinalIgnoreCase) )),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Products"}, {"Products"})
in
#"Expanded Custom"