Getting the maximum value of a column, but it returns the wrong value

Hi, I am a new user.
I am trying to get the maximum/minimum value from a column in an excel file. The data for the excel file was obtained using data scraping on yahoo finance for the past 10 days pricing of the GE stock. As seen in my workflow, I used read column, with output ‘lowColumn’ and ‘highColumn’ for the low and high column in the excel file.

However, the minimum value returns me 10.02 instead of 9.77. It seems that it reads numbers in the 10 as smaller than other numbers. I would need some advice on this.

@shanen Try this lowColumn.AsEnumerable().Min(Function(row) row(“colname”)).ToString

Because the values in excel are interpreted as text, not numbers,therefore “10.02” < “9.77” => see the small green rectangles.

Cheers

Thanks, I think I understand now. So I have to convert the column to integer first and get the minimum and then convert back to string?

Hey @shanen

you can use like this: -

Double MinValue= yourDatatable.AsEnumerable().Min(Function(row) Convert.ToDouble(row("yourColumnName")))

Regards…!!
Aksh

1 Like

Hi @aksh1yadav, this works thank you very much!

Hey @shanen

No worries Dude :slight_smile:

Regards…!!
Aksh

How if column name is not specified