Remove all Duplicates in Datatable

I am looking for a way to remove all duplicates but retain on unique IDs. As an example if I had the below DT:

Column1
1
1
2
3
4
4

I would want the code to remove all duplicates and only report back:

Column1
2
3

@Hurwitzw003
Welcome to the forums:

give a try on following:

Assign activity
LHS: dtResult | DataType: DataTable
RHS:

(From d in YourDataTableVar.AsEnumerable
Group d by k=d("Column1").toString.Trim into grp=Group
Where grp.Count = 1
Select r=grp.First()).CopyToDataTable

Hey, thank you for the quick response. Question about the code, what does r and d mean?

it is acting like references/variables within the LINQ statement

When the code in the assign statement, I get the following: “Name ‘d’ is either not declared or not in the current scope.”

please share a screenshot from your implementation. thanks

Both variables (closeExists and DataTable) is System.Data.DataTable

got it. Just refer to the updated post above

Thanks, that worked perfectly!

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