Linq query to filter datatable

I’m trying to select all rows from a datatable that have column values present in a list. I would prefer to use a linq query as the list will be dynamic and not ideal for filter data table activity

For example, DT1
Col1, Col2
1, dog
2, cat
3, tree
4, big dog

list_for_col2 = “dog, cat”

The output datatable should be
Col1, Col2
1, dog
2, cat
4, big dog


Like this: (8,2 Ko)

The workflow uses LIKE to find if the word is in the column.

give a try on

(From s in searchtermlistvar
From r in yourdatatablevar.AsEnumerable
where r(YourColumnNameOrIndex).toString.Contains(s)
Select r).CopyToDataTable

keep in mind .CopyToDataTable thtows an exception if no rows are returned. Additional Handling of this is possible as well

Updated Flow And LINQ:

(From d In dtData
Where KeyWords.Any(Function (x) d(1).toString.Contains(x))
Select r = d).ToList

Starter Help:
DT_Filter1Col_ByKeyWordList.xaml (9.2 KB)


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