Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Remove duplicate with condition

Hi,    I would like to remove the duplicated names in the table below but before that I would like to copy the Reference value if they have the same name.    I do this because after deleting the ...
  • lbendlin's avatar
    3 years ago

     

    I would like to copy the Reference value if they have the same name. 

     

    I don't understand that part.

     

    What should happen in this scenario?

     

    Do you expect both references to be listed?

     

    Or more like this?

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jVNBCoMwEPyLZ6XRouBR8WIxFY1BiviD0lsP/X034uqabMRbdmYy2U0m0xSMhWp6IeIgDD7f9zuYwwP2vBWR6pqo6RcGlmMtxJ2qCYbqsaZMwqg5LPZglmvbF1LvDJSR1Daz+ciXOx/BjAOU6CD14MxHsEWtB+xkZRJGnXjVMaOOWbXUeZ5basRQvfcNE6XilKE+Zn67b8TQYX3zlbH7PtwgUXeKvg6UWyc7s/k8ytbx5rCqTJy9BDMnQYknQX6dmyaYUUOJN33hBxj18QcwuWRTXFdO3wSDJXW4ktWfIu9ynjQul9fTx6k9SfLnTmTePGVMnlIPRh3mPw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [name = _t, reference = _t]),
        #"Replaced Value" = Table.ReplaceValue(Source,"null",null,Replacer.ReplaceValue,{"reference"}),
        #"Grouped Rows" = Table.Group(#"Replaced Value", {"name"}, {{"Rows", each _, type table [name=nullable text, reference=nullable text]}}),
        #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Reference", each List.First(List.RemoveNulls([Rows][reference]))),
        #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"name", "Reference"})
    in
        #"Removed Other Columns"