DataTable - Remove Duplicate Row

Hello,

Is anyone familiar with Remove Duplicate Rows (from the DataTable Activities)? I am pulling a large data table from SharePoint but I want to delete rows that have the same code in a certain column. So for example I have 5 columns in my data table and a lot of rows. I want to delete duplicates that that are contained in one of the columns. Does that make sense? Can anyone help?

3 Likes

hi @Cormac
try rhis

Thanks
Ashwin S

1 Like

@Cormac

Try below expression.

   newDT = inputDT.DefaultView.ToTable("True","Column1","Column2",...)

Where inputDT is your original input data.

1 Like

Thanks for the response but I don’t want to delete entire columns I just want to delete entire rows where the same code is found in ‘Column 1’. Does that make sense?

1 Like

@Cormac

It won’t delete entire column. It will give all rows which have unique data.

1 Like

OK. I see that it won’t delete the entire columns but it doesn’t seem to work for me. The problem is (i think) that the entire row is not a duplicate. There are duplicates in ‘column 1’. I want to delete the entire row if there are duplicate codes in ‘column 1’ even though column 2,3,4 etc may not be duplicate. So in the screen shot below I want to get rid of test 2 and test 3 (the entire rows) but keep test 1 in the data table

@Cormac

Try this once.

    newDT = inputDT.Asenumerable().Gropyby(Function(a) a.Field(of string)(“ColumnName”)).Select(Function(b) b.First()).CopyToDatatable()
1 Like

Hi
this expression could help you with
datatable = datatable.AsEnumerable().GroupBy(Function(a) a.Field(of string)(“yourcolumnnname”).ToString).Select(Function(b) b.First()).CopyToDatatable()

if you are not getting asenumberable then kindly have a view on this thread

Cheers @Cormac

5 Likes

I can’t get that to validate. Do you know where I am going wrong?

image

1 Like

its CopyToDatatable() buddy at last
you were almost done
Cheers @Cormac

1 Like

That worked! Thanks so much!

1 Like

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