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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
jabrillo
Helper I
Helper I

Split Column into Rows

I have one column with the following data:

RefData
1

20200101 - Juan Perez

The quick brown fox

 

20200102 - Elton Hamilton

Jumped over the lazy dog

2

20200103 - Jacqueline Seymour

When the sun is up

 

20200104 - Jerry Seacrest

And everything is okay

I want to split the second column into three columns and rows depending on the number of line breaks. It should look like this:

RefDateNameComment
120200101Juan PerezThe quick brown fox
120200102Elton HamiltonJumped over the lazy dog
220200103Jacqueline SeymourWhen the sun is up
220200104Jerry SeacrestAnd everything is okay

How will I do this in Power Query? Thank you...

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

You should be able to split the column into new rows using a double line feed and then split again into columns using a single line feed and then once more on " - ".

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TY2xDoIwFAB/5aUzJqX6Aw4mhslEEwfKUOEJDfAKpVXL19saE91uuMuVJctZxgQXnOc8hw0UXhGc0OIq6dIhzF7XPdyseRLczUuSpK8ton0YnCE4qlEnkFT4ccIGzAMtuFgPag3QmJZVWcnE77RNJ1XPHgdNCGcMo/FW0rVD+oSLJ9AL+OlvuEsRWhuir2qLi5O0pwYw3oLrNLUpMb0KrKre", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Ref = _t, Data = _t]),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(Source, {{"Data", Splitter.SplitTextByDelimiter("#(lf)#(lf)", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Data"),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Split Column by Delimiter", "Data", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), {"Date-Name", "Comment"}),
    #"Split Column by Delimiter2" = Table.SplitColumn(#"Split Column by Delimiter1", "Date-Name", Splitter.SplitTextByDelimiter(" - ", QuoteStyle.Csv), {"Date", "Name"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter2",{{"Ref", Int64.Type}, {"Date", Int64.Type}, {"Name", type text}, {"Comment", type text}})
in
    #"Changed Type"

View solution in original post

2 REPLIES 2
AlexisOlson
Super User
Super User

You should be able to split the column into new rows using a double line feed and then split again into columns using a single line feed and then once more on " - ".

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TY2xDoIwFAB/5aUzJqX6Aw4mhslEEwfKUOEJDfAKpVXL19saE91uuMuVJctZxgQXnOc8hw0UXhGc0OIq6dIhzF7XPdyseRLczUuSpK8ton0YnCE4qlEnkFT4ccIGzAMtuFgPag3QmJZVWcnE77RNJ1XPHgdNCGcMo/FW0rVD+oSLJ9AL+OlvuEsRWhuir2qLi5O0pwYw3oLrNLUpMb0KrKre", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Ref = _t, Data = _t]),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(Source, {{"Data", Splitter.SplitTextByDelimiter("#(lf)#(lf)", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "Data"),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Split Column by Delimiter", "Data", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), {"Date-Name", "Comment"}),
    #"Split Column by Delimiter2" = Table.SplitColumn(#"Split Column by Delimiter1", "Date-Name", Splitter.SplitTextByDelimiter(" - ", QuoteStyle.Csv), {"Date", "Name"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter2",{{"Ref", Int64.Type}, {"Date", Int64.Type}, {"Name", type text}, {"Comment", type text}})
in
    #"Changed Type"
smpa01
Community Champion
Community Champion

@jabrillo  question 

does your string look like 

20200101 - Juan PerezThe quick brown fox 20200102 - Elton HamiltonJumped over the lazy dog

or

20200101 - Juan Perez The quick brown fox 20200102 - Elton Hamilton Jumped over the lazy dog

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.