Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Group By and Remove Zero Value Ids

Hi   I have a dataset with an id column a 2 numeric value columns and about 20 categorical columns. Each id has mutliple rows and I would like to group by the id find the ids where the sum of the e...
  • Anonymous's avatar
    Anonymous
    5 years ago

    perpha not the best, but one of ...

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTJUitWJVkoCsozALJCYrjGYmQxiGsHljeHyJnBpQ4R2XVO4PFBlLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, value = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"id", type text}, {"value", Int64.Type}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"id"}, {{"sum", each List.Sum([value]), type nullable number}, {"all",each _}}),
        #"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each [sum] <> 0),
        #"Expanded all" = Table.ExpandTableColumn(#"Filtered Rows", "all", {"value"}, {"value"})
    in
        #"Expanded all"