Forum Discussion

rc_stem's avatar
rc_stem
Frequent Visitor
2 years ago
Solved

erge two columns, both containing multiple tabs, then split column into multiple rows

Wondering if it's possible to merge two columns, both containing multiple tabs, then split column (by tabs) into multiple rows. Please see example: Cashier Customer First Name Last Name Joh...
  • Ashish_Mathur's avatar
    2 years ago

    Hi,

    This M code works

    let
        Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Cashier", type text}, {"Customer First Name", type text}, {"Last Name", type text}}),
        #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each List.Transform(List.Zip({Text.Split([Customer First Name],"#(lf)"),Text.Split([Last Name],"#(lf)")}), each Text.Combine(_," "))),
        #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
        #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Customer First Name", "Last Name"})
    in
        #"Removed Columns"

    Hope this helps.