How to Filter Data Table Using A List of Values

I have a data table that I wish to Filter based on a list of Customer values. Instead of listing each customer value separately, how would I code the Filter to use “Contains” and place customer values in a List.


Hi @randy.stokes

You can achieve this using Assign activity with the IN condition in DataTable.Select() method

dt_Input.Select(“[Customer] in (‘70025369’,‘70025371’,‘70025373’,‘70025375’)”).CopyToDataTable

If you have filter values in Array or List then, you can use the String.Join() to pass value and that will make the query dynamic.

dt_Input.Select(“[Customer] in (”+String.Join(“,”,dt_Input)+“)”).CopyToDataTable



Another approach with LINQ :

arrCustomerValue = {"70025369","70025524","70026089","30052501".......}


PD9_Download_Case = PD9_Download_Case.AsEnumerable.Where(Function(r) arrCustomerValue.Contains(r("Customer").ToString)).CopyToDataTable()


1 Like

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