Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hola
He cargado los siguientes datos de un archivo de Excel:
| Columna 1 | MTD | Hasta la fecha |
| Órdenes | ||
| A | 3.0 | 5.0 |
| B | 8.0 | 10.0 |
| C | 2.0 | 3.0 |
| D | 7.0 | 8.0 |
| Ventas | ||
| A | 7.0 | 9.0 |
| B | 15.0 | 17.0 |
| C | 3.0 | 6.0 |
| D | 5.0 | 7.0 |
| Beneficio | ||
| A | 6.0 | 7.0 |
| B | 4.0 | 6.0 |
| C | 2.0 | 4.0 |
| D | 1.0 | 3.0 |
Me gustaría transformar y transponer los datos al siguiente formato:
| Categoría | Producto | MTD | Hasta la fecha |
| Órdenes | A | 3.0 | 5.0 |
| B | 8.0 | 10.0 | |
| C | 2.0 | 3.0 | |
| D | 7.0 | 8.0 | |
| Ventas | A | 7.0 | 9.0 |
| B | 15.0 | 17.0 | |
| C | 3.0 | 6.0 | |
| D | 5.0 | 7.0 | |
| Beneficio | A | 6.0 | 7.0 |
| B | 4.0 | 6.0 | |
| C | 2.0 | 4.0 | |
| D | 1.0 | 3.0 |
Por favor, hágamelo saber cómo se puede hacer esto
Gracias
Solved! Go to Solution.
Por favor, vea el archivo adjunto a continuación
De nada
Hola @rsrajkumar,
¿Su tabla de entrada es una sola tabla o hay 3 separadas? Si es lo primero, entonces puedes probar estos pasos en Power Query (solo tienes que pegar el código en el Editor avanzado para verlo en acción):
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8i9KSS0qVtJRUgDjWJ1oJUcgy1jPAEiaAkmQiBOQbQEWMTSACjkDOUZgIWOoiAuQbQ4WsYCKKKAYG5yYk4ppEUSHJZJFhqYQm8yRbII4xwzJJogic6w2BRTlp2WWYFhlhqIFZJUJirEIL5kgWWSI8GQsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Product = _t, MTD = _t, YTD = _t]),
#"Added Custom" = Table.AddColumn(Source, "Category", each if [Product] = "Orders" or [Product] = "Sales" or[Product] = "Profit" then [Product] else null),
#"Filled Down" = Table.FillDown(#"Added Custom",{"Category"}),
#"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Product] <> " " and [Product] <> "Sales" and [Product] <> "Orders" and [Product] <> "Profit")),
#"Reordered Columns" = Table.ReorderColumns(#"Filtered Rows",{"Category", "Product", "MTD", "YTD"})
in
#"Reordered Columns"
Tabla de salida:
Hola @wini_R , gracias por su rápida respuesta. Es de una sola mesa. ¿Cuál es la importancia del texto que sigue a "Binary.FromText"?
Hola @rsrajkumar,
Para su solución final no importa, ese paso debe ser reemplazado por sus datos de origen. Está aquí para simplificar el uso compartido de código entre usuarios: cualquiera puede tomar el código y usarlo en su Power Query sin la necesidad de cargar/preparar algunos datos de muestra. Esencialmente, es su tabla de entrada codificada en formato Base64.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.