Forum Discussion

oliverL's avatar
oliverL
Frequent Visitor
5 years ago
Solved

Removing duplicates from table based on certain columns only

Hello,   I need help removing "duplicates" from a table. Let me ilustrate my problem with one example: Name Country Company Age City John Doe US Microsoft 30 Palo Alto John Doe U...
  • CNENFRNL's avatar
    5 years ago

    oliverL , Power Query is competent in such tasks. You might want to try,

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8srPyFNwyU9V0lEKDQYSvpnJRfnF+WklQLaxAZAISMzJV3DMKclXitXBVO5YVVqUClPqm5hSlJmCVZ17fn56DlyhZ1FqTmIeVGViXipMpTeySlMTIOGTn5eSnwdW6JKYp+CdmgdymG8EukstgERIfnZlPrpSHycg4V+UmAyxHaQuuERPwc9bKTYWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Name = _t, Country = _t, Company = _t, Age = _t, City = _t]),
        #"Grouped Rows" = Table.Group(Source, {"Name"}, {{"ar", each try _{[Company="Microsoft"]} otherwise _{0}}}),
        #"Expanded ar" = let cols = List.RemoveItems(Table.ColumnNames(Source),{"Name"}) in Table.ExpandRecordColumn(#"Grouped Rows", "ar", cols, cols)
    in
        #"Expanded ar"