Filter data table by unique data in a specific column

Lets assume your dt has some columns like

Col1,Col2
A,1
A,2
B,1
B,1

And you want deduplicate / distinct on first column & from groups with the same Col1 value we will take the first occurence

For a result as:

Col1,Col2
A,1
B,1

we can do:

Assign Activity:
dtResult | datatype: DataTable =
(From d in YourDataTableVAr.AsEnumerable
Group d by d(“Col1”).toString.Trim into grp=Group
Select r = grp.First()).CopyToDataTable

1 Like