How to Filter Negative Values from Datatable

I need to Filter Negative values from Datatable , if there is no empty cell in a column Cint(x(“Amount”).ToString)<0 is working but if have empty cells the logic throw error like
"input formart not correct" . Please help to Find Solution.

My filter is

GTS_Data.AsEnumerable.Where(Function(x) (x(“Instrument”).ToString.Trim.Contains
(“FX-FORWARD”)) and (x(“Payment Date”).ToString.Trim.ToLower.Contains(Now.AddDays(1Test.xlsx (48.3 KB) ).Date.toString(“M/dd/yyyy”))) and cint(x(“Payment Amount”).ToString.Trim)<0).ToArray

Hi,

Can you try Cdbl instead of Cint?

Regards,

@Prathibabala If you want to consider Empty Cells as 0, Maybe you need to add an If Condition to determine if it is Empty in the below way :

 GTS_Data.AsEnumerable.Where(Function(x) (x("Instrument").ToString.Trim.Contains("FX-FORWARD")) And (x("Payment Date").ToString.Trim.ToLower.Contains(Now.AddDays(1).Date.toString("M/dd/yyyy"))) And CInt(if(String.IsNullOrWhiteSpace(x("Payment Amount").ToString.Trim),"0",x("Payment Amount").ToString.Trim))<0).ToArray

Thank you So much, Its working well.

1 Like