assume you have 2 excels, one is the main excel , one the the excel containing the names to filter by
this is how you can filter dynamically instead of hardcoding a filter datatable activity
1 read “test.xlsx” to dtMain variable
-
read “NamesToFilter.xlsx” to dtNamesToFilter datatable variable
-
initialize a “filterList” and filterString variable
-
loop over dtNamesToFilter, in each iteraction add
"[Name]='"+CurrentRow("Name").ToString+"'"
to filterList
3a. now filteredList looks like this
-
assign
String.Join(" OR ", filterList)
tofilterString
-
this should be the value of filterString
[Name]='John' OR [Name]='Andrew' OR [Name]='Dacia'
-
now simply assign
dtMain.Select(filterString).CopyToDataTable
to a new datatable variable: dtFiltered -
dtFilter will look like this
Test.xaml (7.9 KB)
NamesToFilter.xlsx (8.3 KB)
Test.xlsx (8.4 KB)