cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Split rows into multiple rows by line breaks

Hi guys,

 

Does anyone know if there is a way in Power Query Editor to split rows with line-broken data into multiple rows?

 

So that

 

Column1Column2
Diamond

A

B

C

Quartz

D

E

Pearl

F

G

H

 

Becomes

 

Column1Column2
DiamondA
Diamond

B

Diamond

C

Quartz

D

Quartz

E

Pearl

F

Pearl

G

Pearl

H

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User I
Super User I

Re: Split rows into multiple rows by line breaks

Hi @moll45 ,
Here is the pbix Split rows PBIX 
So I split the 2nd col by delimiter. Which might be the only tricky part for you.  When I built a table to match yours I had to do a "Shift Enter" to get data on subsequent rows visually. You may have to play around with how to split the column, but from there it is easy, select first column and unpivot other rows, then delete attribute column.
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Split23.PNG

 





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

Proud to be a Super User!




View solution in original post

6 REPLIES 6
Highlighted
Super User I
Super User I

Re: Split rows into multiple rows by line breaks

Hi @moll45 ,
What do you mean by Line Broken Data? And are these two columns with the same name?
Nathaniel





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

Proud to be a Super User!




Highlighted
Helper I
Helper I

Re: Split rows into multiple rows by line breaks

Hi @NathP ,

 

I mean data where in one cell there's multiple lines of data, like in the tables above. And sorry, no, they were not meant to have the same name, I've now fixed that.

Super User I
Super User I

Re: Split rows into multiple rows by line breaks

Hello @moll45 ,
Will send the pbix in a minute.

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Split2.PNG

 

Split.PNG

 





From the Advanced Editor

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcslMzM3PS1HSUXKMyXOKyXNWitWJVgosTSwqqQIKusTkucbkuYEFA1ITi3KAYu4xeR5KsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column1.1 = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1.1", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), {"Column1.1.1", "Column1.1.2", "Column1.1.3"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column1", type text}, {"Column1.1.1", type text}, {"Column1.1.2", type text}, {"Column1.1.3", type text}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Column1"}, "Attribute", "Value"),
    #"Removed Columns" = Table.RemoveColumns(#"Unpivoted Other Columns",{"Attribute"})
in
    #"Removed Columns"

 





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

Proud to be a Super User!




Highlighted
Super User I
Super User I

Re: Split rows into multiple rows by line breaks

Hi @moll45 ,
Here is the pbix Split rows PBIX 
So I split the 2nd col by delimiter. Which might be the only tricky part for you.  When I built a table to match yours I had to do a "Shift Enter" to get data on subsequent rows visually. You may have to play around with how to split the column, but from there it is easy, select first column and unpivot other rows, then delete attribute column.
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel
Split23.PNG

 





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

Proud to be a Super User!




View solution in original post

Highlighted
Helper I
Helper I

Re: Split rows into multiple rows by line breaks

Hi @Nathaniel_C ,

 

Thanks Nathaniel, this fixed my problem!

Highlighted
Super User I
Super User I

Re: Split rows into multiple rows by line breaks

Hi @moll45 , you are very welcome!
Nathaniel





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

Proud to be a Super User!




Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors