Distinct Function

Hello everyone !

I am using:

NewDT = MainDT.DefaultView.ToTable(true,“Product”,“Customer”,“Account”,“Location”)

to get these values distinct datatable, but this function remove other columns.
Is there any other solution which keeps related other columns?

@rpa_22
Welcome to the forum

give a try at following:

Assign activity:
LHS: dtDistinct | datatype: DataTable
RHS:

(From d in YourDataTableVar.AsEnumerable
Let k=String.Join("_", {"Product","Customer","Account","Location"}.Select(Function (x) d(x).toString.Trim))
Group d by  k1 = k into grp=Group
Select r = grp.First()).CopyToDataTable

Thanks for quick reply & solution !

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