How to get last item that is numeric in datatable column

Hi

How to get last item that is numeric in datatable column ?

image

thanks

Hi @Suastrian_Dika ,
To retrieve last record in the column
dt.Select("Column0<>''")(dt.Select("Column0<>''").Length-1)("Column0")

Regards,
Arivu

1 Like

Hi,

How about the following expression?

dt.AsEnumerable.Where(Function(r) Double.TryParse(r(0).ToString, new double)).Last().Item(0).ToString

Regards,

1 Like

Hi @Suastrian_Dika ,

Assuming you have read the Data in the Excel sheet as a Datatable, say DT. Then we can get the Last numeric value using the below Expression :

DT.AsEnumerable.Where(Function(x)x("YourColumnName").ToString.IsNumeric).Select(Function(x)x("YourColumnName").ToString).LastOrDefault

If there is no numeric value at all, it returns a null value.

1 Like

Thanks @supermanPunch

1 Like

Thanks @Yoichi

1 Like

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