Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Eliminating duplicates rows in table

My table has the folowwing data. I only want the row where Col2 has the max value. Is there a method to do this at the Table view level? If not what would be an alternative mehtod?   Col1    Col2 ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Anonymous ,

     

    Please try this code in power query advanced editor,

    let
    
        Source = #table(
            {"Col1", "Col2"}, 
            {
                {1, 1},
                {1, 2},
                {1, 3},
                {2, 2},
                {2, 3},
                {2, 4},
                {3, 5},
                {3, 4},
                {3, 3}
            }
        ),
       NewTable = Table.Group(
            Source, 
            {"Col1"}, 
            {{"Col2", each List.Max([Col2])}}
        )
    in
        NewTable

     

    Best Regards,

    Bof