AND/OR condition challenges in Filter Datatable activity

Dear Fellow UiPather,

Recently I have a doubt on the result of filtering datatable.

If I need to apply multiple conditions to the table such as below, then I’m not able to picture the results:

On the contrary, if I need to use a bit complex conditions and write in below format, how can i use filter activity to achieve it?

  1. (Cond_1 AND Cond_2 AND Cond_3) OR (Cond_4 AND Cond_5) OR (Cond_6 AND Cond_7)
    2.(Cond_1 AND Cond_2) OR ((Cond_4 OR Cond_5) AND (Cond_6 OR Cond_7))

Hope someone can help here!

Thanks!
Helliton

Hi

put some value in given screenshot
Then it will work

thanks

I do not think the filter wizard is the best way to achieve this. See here:

If you’d go for the last variant, LINQ, the expression would be something like this:

(From row In MyDataTable.Select()
Where (row(“col_1”).Equals(“something”) && row(“col_1”).Equals(“something”))
|| row(“col_3”).Equals(“something”)

Select r).CopyToDataTable

? Here are some LINQ snippets to look at:

But as you see this is not so elegant.

What about filtering the table one time for (Cond_1 AND Cond_2 AND Cond_3), one time for (Cond_4 AND Cond_5), and so on? This would give you several output tables. Sometimes this is useful. It depends on what you want to do with the data table.

2 Likes

Thanks for the suggestions!

I’ll try it out.

As explained by you, the “filter” activity doesn’t look good for heavy duty jobs. And we need to turn to scripting :slight_smile: