Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Administrator
2 years ago

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 pueden repetir.

Estoy usando la siguiente fórmula, pero solo clasifica 1,1,1,1
= Tabla.Grupo(
Personalizado1,
{"Ciclo", "Usuario", "Cuenta"},
{
{"Puntuación máxima", cada Lista.Max([Puntuación]), escriba el número},
{"Índice", cada Table.AddIndexColumn(_, "Índice", 1, 1), tipo tabla}
}
)

CicloUsuarioCuentaPuntuaciónÍNDICE
AAlexXXy1001
AAlexXXz1002
A

Alex

XXu503
AVikXXc1001
AVikXxv802
AVikXXb803
BAlexXXy1001
BAlexXXz1002
B

Alex

XXu503
BVikXXc1001
BVikXxv802
BVikXXb803

¡Realmente agradezco un poco de ayuda! ¡Gracias!

1 Reply

  • 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/