Get Unique Rows/Count from DataTable

Hi all,

I’m having a complete brain-freeze today and cannot work out how to count the number of unique rows in a datatable.

I have an existing table like this:

And I need to get it to this:

Any help would be appreciated, thanks! :slight_smile:


Check below

Hope this helps you


1 Like

Customized to your case:
(From d In dtData.AsEnumerable
Group d By k1=d(“Postcode”).toString.Trim, k2=d(“Peril”).toString.Trim Into grp=Group
Let ra = New Object(){k1,k2,grp.Count}
Select dtStatistic.Rows.Add(ra)).CopyToDatatable

1 Like

Thank you!

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