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.
Tenemos datos procedentes de una sola lista de SharePoint que tiene varias transacciones en una sola fila o registro para cada equipo.
ID de registro | Equipo | Trans 1 ID | Fecha Trans 1 | Trans 1 Costo | Trans 2 ID | Fecha Trans 2 | Costo Trans 2 | Trans 3 ID | Trans 3 Fecha | Costo Trans 3 |
1 | Equipo A | 45654 | 1/5/2019 | $1,342.22 | 15687 | 4/26/2019 | $7,964.50 | 45897 | 10/10/2019 | $111.12 |
2 | Equipo B | 48996 | 2/5/2019 | $900.00 | 65489 | 3/11/2020 | $121.84 | |||
3 | Equipo C | 98764 | 2/7/2019 | $143.55 | 25489 | 6/1/2019 | $2,319.10 | |||
4 | Equipo D | 78136 | 4/15/2019 | $684.99 | 63632 | 7/6/2019 | $75.88 | 66546 | 1/5/2020 | $600.01 |
En un mundo ideal, creo que los datos se organizarían mejor con cada transacción listada como una fila/registro individual. A continuación, tendríamos una sola columna Trans Date, Trans Cost y Trans ID en lugar de que se repitan en varias columnas.
Dado que este no es nuestro mundo, ¿cuál es la mejor manera de manejar datos como este? Nuestros datos reales tienen aún más columnas de transacción repetidas (50 trans total por registro). ¿Hay alguna manera de combinar columnas (por ejemplo, Fecha Trans 1, Fecha Trans 2, etc.) en una sola columna (Fechas Trans)? ¿Eso es lo que deberíamos estar buscando hacer? Un poco perdido con el formato actual y lo que debemos hacer para cambiarlo y darle forma a algo que se pueda usar para crear informes o paneles en Power BI. Cualquier orientación y ayuda es muy apreciada.
Solved! Go to Solution.
Hola @dsever04 ,
Por favor, siga los pasos que se muestran a continuación
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZZA9bgQhDIWvskIpkeEZMHaZnyOkG02RImXu38YmO+xKkUBYfuazn48jIeX0+f31c3v1oA8Z3V+UUbjCPHxBbp2JOdJDdEZZYdn6zCadRl3f1UJHLX42ACBwOvOR+Gr2FtVqJv7yUzOrlWqgfA6NTCuAq1wXiUEa8932DWq7qO8emE7pizofE/RGY0TyTpWCLXJuMEL9h+0X9sODqWiyrOMxrWgnW7wmLbzN8rSXQaqhuRXZO/0zImET6Tx/AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Record ID" = _t, Team = _t, #"Trans 1 ID" = _t, #"Trans 1 Date " = _t, #"Trans 1 Cost" = _t, #"Trans 2 ID" = _t, #"Trans 2 Date" = _t, #"Trans 2 Cost" = _t, #"Trans 3 ID" = _t, #"Trans 3 Date" = _t, #"Trans 3 Cost" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Record ID", Int64.Type}, {"Team", type text}, {"Trans 1 ID", Int64.Type}, {"Trans 1 Date ", type date}, {"Trans 1 Cost", Currency.Type}, {"Trans 2 ID", Int64.Type}, {"Trans 2 Date", type date}, {"Trans 2 Cost", Currency.Type}, {"Trans 3 ID", Int64.Type}, {"Trans 3 Date", type date}, {"Trans 3 Cost", Currency.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Record ID", "Team"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Attribute.1", "Attribute.2", "Attribute.3", "Attribute.4"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", Int64.Type}, {"Attribute.3", type text}, {"Attribute.4", type text}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Attribute.1", "Attribute.2", "Attribute.4"}),
#"Added Index" = Table.AddIndexColumn(#"Removed Columns", "Index", 1, 1, Int64.Type),
#"Pivoted Column" = Table.Pivot(#"Added Index", List.Distinct(#"Added Index"[Attribute.3]), "Attribute.3", "Value"),
#"Removed Columns1" = Table.RemoveColumns(#"Pivoted Column",{"Index"})
in
#"Removed Columns1"
https://kohera.be/blog/power-bi/how-to-unpivot-twice/
¿He respondido a tu pregunta? Por favor, marque mi respuesta como solución. Muchas gracias.
Si no es así, cargue algunas muestras de datos insensibles y la salida esperada.
Saludos
Eyelyn Qin
Hola @dsever04 ,
Por favor, siga los pasos que se muestran a continuación
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZZA9bgQhDIWvskIpkeEZMHaZnyOkG02RImXu38YmO+xKkUBYfuazn48jIeX0+f31c3v1oA8Z3V+UUbjCPHxBbp2JOdJDdEZZYdn6zCadRl3f1UJHLX42ACBwOvOR+Gr2FtVqJv7yUzOrlWqgfA6NTCuAq1wXiUEa8932DWq7qO8emE7pizofE/RGY0TyTpWCLXJuMEL9h+0X9sODqWiyrOMxrWgnW7wmLbzN8rSXQaqhuRXZO/0zImET6Tx/AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Record ID" = _t, Team = _t, #"Trans 1 ID" = _t, #"Trans 1 Date " = _t, #"Trans 1 Cost" = _t, #"Trans 2 ID" = _t, #"Trans 2 Date" = _t, #"Trans 2 Cost" = _t, #"Trans 3 ID" = _t, #"Trans 3 Date" = _t, #"Trans 3 Cost" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Record ID", Int64.Type}, {"Team", type text}, {"Trans 1 ID", Int64.Type}, {"Trans 1 Date ", type date}, {"Trans 1 Cost", Currency.Type}, {"Trans 2 ID", Int64.Type}, {"Trans 2 Date", type date}, {"Trans 2 Cost", Currency.Type}, {"Trans 3 ID", Int64.Type}, {"Trans 3 Date", type date}, {"Trans 3 Cost", Currency.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Record ID", "Team"}, "Attribute", "Value"),
#"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Attribute.1", "Attribute.2", "Attribute.3", "Attribute.4"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Attribute.1", type text}, {"Attribute.2", Int64.Type}, {"Attribute.3", type text}, {"Attribute.4", type text}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Attribute.1", "Attribute.2", "Attribute.4"}),
#"Added Index" = Table.AddIndexColumn(#"Removed Columns", "Index", 1, 1, Int64.Type),
#"Pivoted Column" = Table.Pivot(#"Added Index", List.Distinct(#"Added Index"[Attribute.3]), "Attribute.3", "Value"),
#"Removed Columns1" = Table.RemoveColumns(#"Pivoted Column",{"Index"})
in
#"Removed Columns1"
https://kohera.be/blog/power-bi/how-to-unpivot-twice/
¿He respondido a tu pregunta? Por favor, marque mi respuesta como solución. Muchas gracias.
Si no es así, cargue algunas muestras de datos insensibles y la salida esperada.
Saludos
Eyelyn Qin
Si selecciona las primeras 2 columnas y 'Despivot otras columnas'
Ahora debería tener 4 columnas. Desea dividir la 3a (columna 'atributo') por delimitador (espacio) para que pueda conservar la columna de números y la columna con ID, Fecha, Costo.
Quite la columna con 'Trans' y cualquier otra columna nula.
Deberías tener 5 columnas ahora.
Pivote en la columna con ID, Fecha, Costo, utilizando Valor como la columna Valores. Elija 'No agregar' en la sección avanzada.
Filtre los valores nulos en la columna ID.
Eso debería funcionar
Puede despotable cada conjunto de columnas (por ejemplo, Trans 1) utilizando la técnica siguiente.
https://datachant.com/2019/10/11/guest-story-unpivot-pairs-of-columns/
Proud to be a Super User!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 |