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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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

Hi @Anonymous ,
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

7 REPLIES 7
Nathaniel_C
Super User
Super User

Hi @Anonymous ,
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!




Anonymous
Not applicable

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.

Hello @Anonymous ,
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!




Hi @Anonymous ,
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!




Spot on, this solve my issue!! Thanks.

Anonymous
Not applicable

Hi @Nathaniel_C ,

 

Thanks Nathaniel, this fixed my problem!

Hi @Anonymous , 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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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