Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreThe FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now
Hola
Aprecio si alguien pudiera ayudar.
Estoy intentando pivotar un conjunto de datos, pero PQ devuelve errores. Intenté insertar una columna de índice, pero no pareció ayudar. Tal vez lo agregué mal.
Esta es la tabla que tengo:
Lo que quiero lograr pivotando las columnas.
Conjunto de datos con los pasos que hice:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("zZXRboIwFIZfpeF2im2lgJeoxJBF1wjuxnlBXFWyWRZgxsffqZkmyhYM2rGrc5o0/fK1f9v53KAd6nYopl2jZQRyhzgn0DmYEAyVMuJCUa2//xAyF9AN0q1q4yJJJYIxT/MikWvo+rMwmPhhiGaTIArV1MhYtO4MGfrcm0ZjfxLBYPwYjZB1BaRLLNNht7iEng5MUzbe87+woWplm7qm1pjVotRzcVzT1pmyOpBmTKoS9icmlqpuj92mUpWvWpR6LoQQs6f1HauHacqmKmX6bEYY4+7h4DFm5HtxbBJ2xvD3y00s1wINk9VKZEIuRX5u9B7Lt1O9CtK+D8U+QjgP2sDpWWrgMHr4jonDcGnHvNedyIokh0XRyyfG1EY8S7ep2sEL4K93SCu2dHCNuJ6uWAOupMNK4QHO4R5YP/2AfUgEGmzibC3yIzGQBaQoL6rexacp1w09sxw9wM4uvgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [postingDate = _t, documentNumber = _t, accountNumber = _t, debitAmount = _t, creditAmount = _t, account.category = _t, account.subCategory = _t, account.accountType = _t, dimensionSetLines.displayName = _t, dimensionSetLines.valueCode = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"postingDate", type date}, {"documentNumber", type text}, {"accountNumber", Int64.Type}, {"debitAmount", type number}, {"creditAmount", type number}, {"account.category", type text}, {"account.subCategory", type text}, {"account.accountType", type text}, {"dimensionSetLines.displayName", type text}, {"dimensionSetLines.valueCode", type text}}),
#"Grouped Rows1" = Table.Group(#"Changed Type", {"postingDate", "documentNumber", "accountNumber", "debitAmount", "creditAmount", "account.category", "account.subCategory", "account.accountType", "dimensionSetLines.displayName"}, {{"Dep2", each _, type table [postingDate=nullable date, documentNumber=nullable text, accountNumber=nullable number, debitAmount=nullable number, creditAmount=nullable number, account.category=nullable text, account.subCategory=nullable text, account.accountType=nullable text, dimensionSetLines.displayName=nullable text, dimensionSetLines.valueCode=nullable text]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows1", "Index", each Table.AddIndexColumn([Dep2],"Index",1)),
#"Expanded Index" = Table.ExpandTableColumn(#"Added Custom", "Index", {"dimensionSetLines.valueCode", "Index"}, {"Index.dimensionSetLines.valueCode", "Index.Index"}),
#"Removed Columns5" = Table.RemoveColumns(#"Expanded Index",{"Dep2"}),
#"Pivoted Column1" = Table.Pivot(#"Removed Columns5", List.Distinct(#"Removed Columns5"[dimensionSetLines.displayName]), "dimensionSetLines.displayName", "Index.dimensionSetLines.valueCode")
in
#"Pivoted Column1"
Atentamente
Zosy
Este tomó un poco de ejercicio.
El código que ha publicado funciona (es decir, no hay errores) pero no da el resultado que desea. Creo que esto ha confundido a la gente, me confundió a mí) porque esperaba código con el error.
De todos modos, el código publicado es su intento de solucionar el problema y creo que tiene el enfoque correcto.
Sin embargo, después del paso 'Índice expandido', los tipos de datos en las 2 últimas columnas son 'Cualquiera' y esto evita que el Pivot funcione de la manera que desea.
Así que asigne el tipo de datos correcto en esas dos últimas columnas y creo que funcionará.
No lo he revisado demasiado de cerca, por lo que aún tendrá que hacer sus propias pruebas.
Déjame saber cómo va
Disculpas por la confusión. De hecho, era solo el tipo de datos para la columna de índice. Realmente aprecio su ayuda.
Si hace clic en el error, recibirá el mensaje de error donde puede tener una idea de cuál podría ser el problema.
Miré para ver qué estaba mal y comencé a buscar en línea cómo podría solucionarlo. En la mayoría de los casos, las personas lo arreglaron agregando una columna de índice y una función Agrupar por. Yo también lo intenté pero no me devolvió lo que necesito.
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.