Filtering Datatable Using Array of String

Hello! I am very new to UiPath and I am still learning about enumerable functions.

I have a data table and I want to filter to only see rows in which ColumnA contains at least one of the items in an array of string. The number of strings in the array can vary.

Array of string example = “222,444,888”
Filter column (keep) = ColumnA

Desired outcome: all rows in which ColumnA contains “222” or “444” or “888”

@benjiherb

Please try with linq query as below

dt.AsEnumerable.Where(function(x) arr.Any(function(y) x("ColumnA").ToString.Contains(y))).CopyToDatatable

dt is the datatble
arr is the array containing your strings

cheers

2 Likes

Thank you so much for replying! Do I use an assign activity for this?

@benjiherb

Yes

dt = dt.AsEnumerable.Where(function(x) arr.Any(function(y) x("ColumnA").ToString.Contains(y))).CopyToDatatable

cheers

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