Need to group data in datatable

Hi All,

I have data in datatable type variable. And here “policynumber” column has duplicate values. So, I need to group this.

Any suggestions?

1 Like


What action do you want to take with the duplicate values? Just highlight any policy numbers which have duplicates?


grouping by policy number.

Output would be like :-

Hi @shuklarchana001 ,

Is this what you were looking for?


dt_sampleData.AsEnumerable.GroupBy(Function(g) g("PolicyNumber").ToString.Trim).Select(Function(s) s.CopytoDataTable).ToList()


GroupandSeperate.xaml (10.3 KB)

Kind Regards,
Ashwin A.K

1 Like

Hi @shuklarchana001,

Give @ashwin.ashok’s answer a go.

If you simply just wanted to order the data, which would group duplicate PolicyNumbers, but keep it all in one DataTable, try this:

yourDT.AsEnumerable.OrderBy(function (x) x.Item("PolicyNumber")).CopyToDataTable

Kind Regards

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