Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Power query Remove Duplicates with two sorting tables

Hi, I have a problem with remove duplicates. I want to remove duplicates, but sorting should be on two tables: with one table it is working, but with two not. #"Removed Duplicates" = Table.Distin...
  • Mariusz's avatar
    6 years ago

    Hi Anonymous 

     

    You can use Group By and adjust the code like below.

    let
        Source = Table,
        #"Grouped Rows" = Table.Group(Source, {"Case"}, {{"tbl", 
            ( rows ) => let  
                sort = Table.Sort( rows ,{{ "key 1", Order.Ascending}, {"Key 2", Order.Ascending}}),
                topRow = Table.FirstN( sort , 1)
            in 
                topRow, type table [key 1=number, Key 2=number]}}),
        #"Expanded tbl" = Table.ExpandTableColumn(#"Grouped Rows", "tbl", {"key 1", "Key 2"}, {"key 1", "Key 2"})
    in
        #"Expanded tbl"

     

    Best Regards,
    Mariusz

    If this post helps, then please consider Accepting it as the solution.

    Please feel free to connect with me.
    LinkedIn