Filtering A Datatable thru a String-type Column with a specific Int value

Problem:
I need to get the datatable that have values 1231-1250 in the Account_No column.

Given:
image

I should only get:
Account_No
1231-bc
1232-dg
1234-ab
1239-dn
1250-as

Is there a way to get the substring of the values in Account_No to get the first 4 digits then convert them to int32? Then afterwards, we filter the data via account_no >1231 AND account_no< 1250?

Thanks!

@Michael_de_Borja

  1. use Read Range activity to iterate that data and will give you output as dataTable and say ‘DT’

  2. Then apply below query to get the required results:

newDT = DT.AsEnumerable().Where(Function(row) Cint(row(“Account_No”).ToString.Split("-".TocharArray)(0)) > 1231 AND Cint(row(“Account_No”).ToString.Split("-".TocharArray)(0)) < 1250).CopyToDataTable

5 Likes

Awesome! Thanks a lot!!

1 Like

Hi! Suddenly having error :frowning:

image

The datatable has values but it returns no datarow exists.

Please advise.

Thank you!

image

image

@Michael_de_Borja

In your expression, mentioned like > 123 and < 124. Because of that your are not getting any data rows. Please check once.

Oh! Thanks a lot!

1 Like

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