Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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
Column1 | Column2 |
Diamond | A B C |
Quartz | D E |
Pearl | F G H |
Becomes
Column1 | Column2 |
Diamond | A |
Diamond | B |
Diamond | C |
Quartz | D |
Quartz | E |
Pearl | F |
Pearl | G |
Pearl | H |
Solved! Go to 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
Proud to be a Super User!
Hi @Anonymous ,
What do you mean by Line Broken Data? And are these two columns with the same name?
Nathaniel
Proud to be a Super User!
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
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"
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
Proud to be a Super User!
Spot on, this solve my issue!! Thanks.
Hi @Anonymous , you are very welcome!
Nathaniel
Proud to be a Super User!
User | Count |
---|---|
140 | |
113 | |
104 | |
77 | |
65 |
User | Count |
---|---|
136 | |
117 | |
101 | |
71 | |
61 |