Delete duplicate rows based on three columns

I need help. I want to learn how to remove duplicate rows base on three columns or more. I have a datatable for example
duplicate sample
i want to get only the first one duplicate and remove the rest duplicate.
How can i achieve this?
i already tried : dt= (From roww In dt_leads.AsEnumerable() Group By idk=New With {key .i=roww.item(“col1”),key .d=roww.item(“col2”),key .k=roww.item(“col3”)} Into gg=Group Select gg(0)).copytodatatable
but it;s not working. please help me…

find starter help here:
FindFirstFromGroup_By3Cols.xaml (12.5 KB)

Hi i don’t get it. How can i tell if what row should base where the duplicates are? For example the duplicate rows are based in Column1, Column3 and Column 4. The dt consist of 5 columns like Column1, Column2, Column3, Column4, and Column5.


related to the provided XAML give a try for your case on following statement:

(From d In dtData
Group d By k1=d("Column1").toString.Trim, k2=d("Column3").toString.Trim,k3=d("Column4").toString.Trim Into grp=Group
Select grp.First()).toList 

It is grouping the rows based on these 3 columns and is taking the first group member row

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.