cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
briandon1970
New Member

Splitting multiple comma delimited cells into multiple rows, keeping row details

Hi all,

 

I'm looking to write a Power Query function or Excel macro which would transform something like the first example below into something like the second - does anyone please have any suggestions?

 

Thanks so much.

 

pic1.png

 

pic2.png

 

 

-Brian

 

1 ACCEPTED SOLUTION
v-cherch-msft
Microsoft
Microsoft

Hi @briandon1970

 

You may use ‘Split Column’ for the 3 columns in Query Editor. 

a.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-cherch-msft
Microsoft
Microsoft

Hi @briandon1970

 

You may use ‘Split Column’ for the 3 columns in Query Editor. 

a.png

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
MFelix
Super User
Super User

Hi @briandon1970

 

This is not directly made in PBI you can use this post to give you the expected result.

 

Using you data and this post I was abble to get the expected result see the M Code below.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8slMTs0rzi8yVNJRCijKz0pNLjHUUYCyjICCIUBuCIgRFAxkBQUbKcXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Licensor = _t, Projects = _t, Territories = _t, RightSummary = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Licensor", type text}, {"Projects", type text}, {"Territories", type text}, {"RightSummary", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Project", each Text.Split([Projects],", ")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Territorie", each Text.Split([Territories],", ")),
    #"Added Custom3" = Table.AddColumn(#"Added Custom1", "Summary", each Text.Split([RightSummary], ", ")),
    #"Added Custom2" = Table.AddColumn(#"Added Custom3", "Custom.3", each Table.FromColumns({[Project],[Territorie],[Summary]})),
    #"Expanded Custom.1" = Table.ExpandTableColumn(#"Added Custom2", "Custom.3", {"Column1", "Column2", "Column3"}, {"Column1", "Column2", "Column3"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom.1",{"Projects", "Territories", "RightSummary", "Project", "Territorie", "Summary"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Column1", "Projects"}, {"Column2", "Territories"}, {"Column3", "RightSummary"}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Licensor", type text}, {"Projects", type text}, {"Territories", type text}, {"RightSummary", type text}})
in
    #"Changed Type1"

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!