How to Remove Duplicate Row If the Value from two Columns matched

Hi @Shinjid ,

Do you want to eliminate just the duplicates or remove those entries which contain duplicates completely?

If its the former, then this ought to do the trick:

image

Dt_sampleData.AsEnumerable().GroupBy(Function(g) Tuple.Create(g("ID").ToString,g("Name").ToString)).Select(Function(s) Dt_sampleData.Clone.LoadDataRow(s.First().ItemArray,False)).CopyToDataTable()

And if its the former then this is the code that will help you out with that:

image

Dt_sampleData.AsEnumerable().GroupBy(Function(g) Tuple.Create(g("ID").ToString,g("Name").ToString)).Where(Function(w) w.Count=1).Select(Function(s) Dt_sampleData.Clone.LoadDataRow(s.First().ItemArray,False)).CopyToDataTable()

RemoveDuplicateRowsBasedOnColumns.xaml (6.8 KB)

Kind Regards,
Ashwin A.K

3 Likes