Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Tengo una columna con los siguientes datos:
Ref | Datos |
1 | 20200101 - Juan Perez El zorro marrón rápido
20200102 - Elton Hamilton Saltó sobre el perro perezoso |
2 | 20200103 - Jacqueline Seymour Cuando sale el sol
20200104 - Jerry Seacrest Y todo está bien |
Quiero dividir la segunda columna en tres columnas y filas dependiendo del número de saltos de línea. Debería verse así:
Ref | Fecha | Nombre | Comentario |
1 | 20200101 | Juan Perez | El zorro marrón rápido |
1 | 20200102 | Elton Hamilton | Saltó sobre el perro perezoso |
2 | 20200103 | Jacqueline Seymour | Cuando sale el sol |
2 | 20200104 | Jerry Seacrest | Y todo está bien |
¿Cómo lo haré en Power Query? Gracias...
Solved! Go to Solution.
Debería poder dividir la columna en nuevas filas usando una alimentación de línea doble y luego dividirla nuevamente en columnas usando una sola fuente de línea y luego una vez más en " - ".
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"
Debería poder dividir la columna en nuevas filas usando una alimentación de línea doble y luego dividirla nuevamente en columnas usando una sola fuente de línea y luego una vez más en " - ".
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"
@jabrillo pregunta
¿Tu cadena se ve como
20200101 - Juan PerezThe quick brown fox 20200102 - Elton HamiltonJumped over the lazy dog
o
20200101 - Juan Perez The quick brown fox 20200102 - Elton Hamilton Jumped over the lazy dog