Forum Discussion

lucho's avatar
lucho
New Member
5 years ago
Solved

Ir contando repetidos con power Query

Buenas tardes, saben cómo ir contando valores repetidos desde power query?

 

Sucede que en la base que tengo yo elimino duplicados, pero en estos momentos, requiero tener otra tabla con los valores duplicados que fueron eliminados. Entonces se me ocurre contar para después hacer filtros (Si saben de otra solución también me sería útil)

  • Hello lucho 

     

    you can use the groupfunction and apply the function to count rows.

    Here an example where I first make distinct values of a table and then a row count with table.group using the basic table.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1UElnXCQzjAyFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DoubleValues = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"DoubleValues", type text}}),
        #"Removed Duplicates" = Table.Distinct(#"Changed Type"),
        Count = Table.Group
        (
            #"Changed Type",
            "DoubleValues",
            {{"Count", each List.Count(_[DoubleValues])}},
            GroupKind.Global
        )
    in
        Count

    Copy paste this code to the advanced editor in a new blank query to see how the solution works.

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy

1 Reply

  • Jimmy801's avatar
    Jimmy801
    Community Champion

    Hello lucho 

     

    you can use the groupfunction and apply the function to count rows.

    Here an example where I first make distinct values of a table and then a row count with table.group using the basic table.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1UElnXCQzjAyFgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [DoubleValues = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"DoubleValues", type text}}),
        #"Removed Duplicates" = Table.Distinct(#"Changed Type"),
        Count = Table.Group
        (
            #"Changed Type",
            "DoubleValues",
            {{"Count", each List.Count(_[DoubleValues])}},
            GroupKind.Global
        )
    in
        Count

    Copy paste this code to the advanced editor in a new blank query to see how the solution works.

    If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
    Kudoes are nice too

    Have fun

    Jimmy