Filter data table by unique data in a specific column

Would like to filter my data-table by a specific column so that each value in that column is unique. I am keeping all the columns in the output data table.

can you give an example of input and expected output?

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

Thank you.

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