Forum Discussion

Mythicos's avatar
Mythicos
Frequent Visitor
2 years ago
Solved

Remove rows in Power Query based on multiple logical criteria

Hi,   I have a table with 3 columns:   [ID]: Whole Number [Informations]: Text [Info quality]: Whole Number, from 1 to 4   I want to keep one row for each distinct [ID], but the row I keep mu...
  • SachinNandanwar's avatar
    2 years ago

    rowstobedeleted= Table.Sort(Yoursource,{{Quality, Order.Ascending}})

    and then you could use Table.Distinct to remove the duplicates.

  • Ashish_Mathur's avatar
    2 years ago

    Hi,

    This M code works

    let
        Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Informations", type text}, {"Info Quality", Int64.Type}}),
        #"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {{"Count", each Table.Min(_,"Info Quality")}}),
        #"Expanded Count" = Table.ExpandRecordColumn(#"Grouped Rows", "Count", {"Informations", "Info Quality"}, {"Informations", "Info Quality"})
    in
        #"Expanded Count"

    Hope this helps.