Remove empty rows before apply condition on that row in Linq

Hi @ppr

I have a variable amount contains value 300 and a datable with columns debit and credit.

I need to check if the amount is in the debit column which will have 300.00 and sometimes debit column will have empty values

image

I am able to compare with simple linq but getting error if the debit value is empty. Could you pls help in applying condition to remove empty values in debit before using linq condition and getting syntax error when trying this.

This is the linq using

It will work only if debit column is not empty. If it is empty will get error conversion from “” to double.

Thanks,
Boopathi

HI, This exception occurs if the value you’re trying to find is not available in that column.

I have used Query syntax to replicate your scenario. But it shouldn’t be any different.

With the same query, first take a count on the number of rows returned to an int32 variable before converting it into list.
image

Then you can have a condition to have count greater than 0 to avoid exceptions.
image

When the condition is satisfied, using the same query, put it into a list.
image

let me know if this works for you :slight_smile:

Hi,

How about the following expression?

InputDataTable.AsEnumerable.Where(Function(r) r("Debit") isnot Nothing AndAlso IsNumeric(("Debit").toString) AndAlso Double.Parse(r("Debit").ToString).Equals(Double.Parse(amount.toString))).toList

Regards,

Hi @Boopathi,

you can also use fiter datatable activity to remove the rows with empty values and then apply your linq on the output dt, this wuld work fine.

Thanks,
Shikhar

Hi @Yoichi

I was trying a query similar to this but it returning 0 but i have 2 values under debit - 300.00 and amount variable is 300. I have attached xaml. FilterLinq.xaml (10.6 KB)

Thanks,
Boopathi

HI @Shikhar_Tandon

Yes, but i am trying to filter data only using Linq so trying Linq queries.

Thanks,
Boopathi

Hi,

I just modified your xaml as the following. can you try it?

FilterLinq.xaml (10.6 KB)

Regards,

1 Like

@Yoichi Thanks a lot. Got it

1 Like

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