Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
rc_stem
Frequent Visitor

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:

CashierCustomer First NameLast Name
JohnBob
Laura
Michael
Smith
Williams
Johnson
SallyPaul
Kara
Rob
Lee
Levy
Branch

Merge Rows:

CashierCustomer Full Name
JohnBob Smith
Laura Williams
Michael Johnson
SallyPaul Lee
Kara Levy
Rob Branch

Seperate tabs to create individual rows

CashierCustomer Full Name
JohnBob Smith
JohnLaura Williams
JohnMichael Johnson
SallyPaul Lee
SallyKara Levy
SallyRob Branch
1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

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.

Ashish_Mathur_0-1721359283775.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

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.

Ashish_Mathur_0-1721359283775.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yaningy-msft
Community Support
Community Support

Hi, @rc_stem 

Thanks for @NaveenGandhi reply, you can try the following steps to realize your need.

Step1: Select the two columns you want to merge and use the Merge Columns function to merge them.

vyaningymsft_0-1721355815984.png

Steps2: Use the Fill Down function to fill the Cashier columns.

vyaningymsft_1-1721355926857.png

Result: 

vyaningymsft_2-1721356001672.png


Best Regards,
Yang

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

NaveenGandhi
Super User
Super User

Hi @rc_stem 

Provide a sample data file to understand the problem better.

Regards,
NG

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.