Distinct Value from Data table specific column


I am not getting the desire result which fetching the distinct value from the data table based on one column below is the example.

I want to get distinct data based on name col.

I have tried below


Please help me in this

Assign Activity
LHS: dtCleansed | DataType: DataTable

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

Hi @Harbansh_Singh ,

It seems you are using id and course also

Have you tried Dttest.defaultview.Totable(true,“name”)

1 Like

Thanks @ppr it worked

Hi @Sam_Abraham with the given solution it will return only name column not I’d and Course

@ppr how can we group by 2 column
Need to write seperate group by clause for that column? It i want to include Course Column also in group by

(From d in YourDataTableVar.AsEnumerable
Group d by k1=d("Name").toString.Trim, k2=d("Course").toString.Trim into grp=Group
Select r=grp.First()).CopyToDataTable

For more info on LINQ also have a look here:
[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum


Thanks you @ppr for the linq link

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