Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Combining value of rows keeping all columns

Hi all,   I have some data where I have some of the rows repeating many times but with a different numerical value (quantity), where I would simply like to combine it into one unique row per unique...
  • HotChilli's avatar
    6 years ago

    A 'Group By' solves this. Select multiple columns before clicking 'Group By'

     

    Am I missing something?

  • mussaenda's avatar
    6 years ago

    Hi Anonymous ,

     

    HotChilli  is right.

    On power query there is a Group By function where you can group this.

    Make  sure you go to advanced option so you can add more columns while grouping

    Then select the sum on the lower part and select the column you want to sum.

     

    Hope this helps!

  • v-xuding-msft's avatar
    6 years ago

    Hi Anonymous ,

     

    They both are right. I just add an image and relative code.

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCg1W0lHySy1XiMwvygYyg/NLSzKAtGticQmQMjQwUIrVIajMFEmVU35xSX4eSHl+EVhNeCpYjRHUKOfEvMSURKBAWGJecn5pWWoRplpjEtSa4FGK7hsjNLW++XklRamJOUhKoaYagoyNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Country = _t, City = _t, #"N/S" = _t, #"W/E" = _t, Sales = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Country", type text}, {"City", type text}, {"N/S", type text}, {"W/E", type text}, {"Sales", Int64.Type}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"Country", "City", "N/S", "W/E"}, {{"Sum", each List.Sum([Sales]), type nullable number}})
    in
        #"Grouped Rows"

     

  • HotChilli's avatar
    HotChilli
    5 years ago

    Group By Order Number and Purchase Number

    and use aggregations on: Sum of Quantity     and Max of Date