Forum Discussion
Syndicate_Admin
2 years agoAdministrator
Filas de recuento de Power Query
¡Hola! Me gustaría agregar un índice de columnas como el que puedes ver a continuación. El índice debe contar las cuentas por usuario y Cyle ordenadas de mayor a menor. Las partituras se pued...
Syndicate_Admin
2 years agoAdministrator
Hola @mbosch ,
¿Qué te parece esto? 🙂
NewIndex fue la columna que creé.
Aquí el M coed que puedes pegar en el editor avanzado:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUXLMSa0AUhERlUDS0MAARCrF6qBJVsEljTAlS4GkKUjOGC4XlpkNlkrGYihMrgxIWqAaCZNKgklBTHTC504nfO50wuNOJzzudMLtTicc7owFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Cycle = _t, User = _t, Account = _t, Score = _t, INDEX = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Cycle", type text}, {"User", type text}, {"Account", type text}, {"Score", Int64.Type}, {"INDEX", Int64.Type}}),
#"Sorted Rows1" = Table.Sort(#"Changed Type",{{"Score", Order.Descending}}),
#"Grouped Rows" = Table.Group(#"Sorted Rows1", {"Cycle", "User"}, {{"Grouping", each _, type table [Cycle=nullable text, User=nullable text, Account=nullable text, Score=nullable number, INDEX=nullable number]}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn ( [Grouping], "NewIndex", 1 )),
#"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
#"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"Cycle", "User", "Account", "Score", "INDEX", "NewIndex"}, {"Cycle", "User", "Account", "Score", "INDEX", "NewIndex"})
in
#"Expanded Custom"
Tomé la idea de aquí.
Hazme saber si esto resuelve tu problema 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/