Filter datatable if it contains part of a string?

Capture

On the left is the datatable to filtered, and on the right is a string to filter the datatable by.
It should look like this after filtering.

Capture2

Any help will be appreciated, thanks

@Aaronlim - pls use Filter datatable activity
and provide datatable name in input datatable and provide filterdatatable in output datatable

in column section provide columname of the datatable and choose Operation as contains and provide the value as “apple”
select Or
in column section provide columname of the datatable and choose Operation as contains and provide the value as “orange”
select Or
in column section provide columname of the datatable and choose Operation as contains and provide the value as "watermelon "

1 Like

@Aaronlim ,

  1. Read the Data in dataTable say - dt_Main
  2. take a string Variable say strFruitNames having Values as CommaSeparated: ‘Apple’,‘Orange’,‘WateMelon’.

Use the below in a Assign - This will return you and DataTable with filteredData

image

OR
You can make use of FilterDataTable Activity


Mukesh

1 Like

hi, the string on the right is dynamic so i cant hard code it

how can i use filter datatable activity in this situation?

If you have dynamic values , then you can go by the first approach ,

Create a dynamic string variable having comma separated fruit names in single quote and then use the same in dt.select query as shown above.


Mukesh

does it have to be in single quotes or can i just use the string on the right?

@Aaronlim - can you share a sample dynamic datatable looks?
you know which columns to find these details?

1 Like

So , LINQ Query Would be like

FruitNames in (‘Apple’ , ‘Orange’,‘WateMelon’)

Since we have String Names to Filter - We have to use them in Single Quotes .

strFruitNames should have Value : ‘Apple’ , ‘Orange’,‘WateMelon’


Mukesh