Get The Max Value For column In Datatable

Hi,

Kindly I need your help, I tried to get the max value from a column in datatable but when I used " dt.AsEnumerable().Max(Function(row) cint(row(“ColumnName”)))" I got an error AsEnumerableis not a member of system.data.datatable.

Hi @aalaghbari,

I faced the same issue on the latest version 2020.4.0 This is a bug. Previously version does not have this issue. Temporary workaround, reuse an existing project from previous version 2019.10.x

Is there another way to get the max value?

Hi @aalaghbari,

There is a manual workaround. See Bug(?) - Cannot access datatable.AsEnumerable.Sum - #8 by pduffy

Add System.Data.DataSetExtensions. Example shown

@aalaghbari - you can try alternate option → do an order by and take top 1 row from dataatable…- like below

DT1 = DT.AsEnumerable().OrderBy(Function (row) Convert.ToInt32(row(“Quantity”))).Take(1).CopyToDataTable()