Filter a data table if contains

datatable

#1

Hi everyone!

I need to filter a datatable if the column “result” cointains the string “ok”.

How can i do?

Thank you


#2

Hey @Siltra,

You can use filterDataTable activity :slight_smile:
Just fill in the appropriate values

!


#3

I update all my packeges but I dont’t have this activity :frowning:

Is it possible by select method?


#4

It should be under Data Table heading in the activities column!!


#5

this is what I have…


#6

That’s a bit weird.There should be like 10 more activities there!

Anyways, you can do it with select too…but still you’ll require Add Data Column activity which i again don’t see there!
Try reinstalling the UiPath.Database.Activities package…It’ll be difficult to work without those activities!
Should look like this!


#7

I have Add Data Column Activity. How can I use this to filter data table?

image


#8

Hello @Siltra,

Please refer to the workflow i created for you :slight_smile:
So what we can do is use select to get the data rows that have result column value ‘ok’
Select returns an array of data rows.
Then we can build a new datatable and through foreach and add data row add the filtered rows in the new data table!Main.xaml (11.3 KB)


#9

Thank you very much for your helping, but the I need rows where column result CONTAINS the string ok, so I can’t use equals operation.


#10

Because you need a contains and not an equal to, I would build a second datatable and loop through the first. Each time it comes across a value containing “OK”, add that row to the second datatable.


#11

So is not possible to do it without a loop only using the select method? I just to count the number of rows, so I don’t need to build the data table after this operation.


#12

Hi @Siltra, the filter data table options are available in version 2018.2.0. May be try to install the latest version. It might work. .!!

Thanks…!!


#13

Hey @Siltra,

You can try using dt.Select(" result=’* ok *’ " )
it will get you the rows having
sometext(space)ok(space)sometext


#14

Hi - You can filter the DataTable like this.

here outDt is a dataTable Variable.

Thank you,
Nitesh


#15

@Siltra
I tried using dt.Select(“result LIKE ‘%ok%’”)
Works just fine! :slight_smile: