Forum Discussion
Removing duplicates with two columns
Hey everyone
I have two columns with email lists 1 and 2, now what I want to do is check and remove duplicate values from both the columns irrespective of their orders.
I have tried the following
If some one can please help with detailed solution would be appreciated, thanks in advance
Hi,
This M code works
let Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content], #"Added Custom" = Table.AddColumn(Source, "Count", each List.Count( Table.SelectRows( Data, (MyVariable) => MyVariable[Email list 1]=[Email2] ) [Email2] )) in #"Added Custom"Hope this helps.
10 Replies
- AnonymousNot applicable
Anonymous you want it to be removed from both the columns or any of the column values should contain and other one should be replace with null??
- AnonymousNot applicable
I want it to be removed from only one coloumn
- AnonymousNot applicable
Anonymous try this in power query.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckxKdkjPTczM0UvOz1XSUQrPL8rOzEt3qEzMyM8Hi8XqRCslpaCpKk91qEotQijA1KajVJ6aA2SkImkEq0TWqqNUkpGYl12ZX4qmKiWxLBVqWGYeUBmqM2NjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Email1 = _t, Email2 = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Email1", type text}, {"Email2", type text}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "C", each if List.Contains(Source[Email1], [Email2]) then null else [Email2]) in #"Added Custom"You can remove the email2 column after the last step.
Accept the solution if that works.
- Ashish_MathurSuper User
Hi,
What result are you expecting. Show that clearly.
- AnonymousNot applicable
Hey Ashish
I am expecting the outcome to be somewhat like this.
Email1 vs Email2 True if any of email matches in both the columns and false if the data is only in email2
- Ashish_MathurSuper User
Hi,
This M code works
let Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content], #"Added Custom" = Table.AddColumn(Source, "Count", each List.Count( Table.SelectRows( Data, (MyVariable) => MyVariable[Email list 1]=[Email2] ) [Email2] )) in #"Added Custom"Hope this helps.
- AnonymousNot applicable
Still doesn't work, should I update the text to something (marked in yellow)
- v-henryk-mstfCommunity Support
Hi Anonymous ,
Whether the advice given by Ashish_Mathur @ has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out
Looking forward to your feedback.
Best Regards,
Henry