How can i find the Maximum Occurrence of a value in a column of a datatable

Hi,

If you want to get the most occurrence values in a column, the following will help you.

Value

dt.AsEnumerable.GroupBy(Function(r) r("ColumnName").ToString).OrderBy(Function(g) g.Count).Last().First().Item("ColumnName").ToString()

Count

dt.AsEnumerable.GroupBy(Function(r) r("ColumnName").ToString).OrderBy(Function(g) g.Count).Last().Count

Regards,

2 Likes