How to filter by an array of strings?

Dear developers… I have a sample here which I will split string and store it in an array of strings. for example below if I split string by comma… I will get (RHB02-0301) (RHB02-0302) (RHB02-0303) which I will get as an array of strings
dta2
how to filter a datatable by an array of strings like below sample… filtering the column “item number” with the obtained array of string should get the result like this: :
data1

your help is much appreciated, Thank You.

2 Likes

Hello @Yusuf_Rahmaniac
You can do this using LinQ query

Check this workflow for better understanding…Let me know about it

check column.xaml (7.2 KB)

Note:-This LinQ code will remove all the records present in the array if you want to keep the records just change condition to True in the code

1 Like

Hi,

Hope the following expression helps you.
(Let’s say arrStr={“RHB02-0301”, “RHB02-0302”, “RHB02-0303”} )

dt = dt.AsEnumerable.Where(function(r) arrStr.Contains(r("Item Number").ToString)).CopyToDataTable

Regards,

4 Likes

Dear Yoichi, your solution worked but can I know how to include headers as well? Thank you sir!!

1 Like

Dear vickydas, Thank You.

Hi,

Do you mean you want to include header to datatable? or want to evaluate if header include these string? I’m glad if you give me an example what you want to achieve.

Regards,

Dear Yoichi, I must have overlooked. your solution works perfectly for my case. thank you so much

1 Like

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