Filter data table-error multiple columns

Hi
I have used Filter data table activity.
Column1=“Standard” or Column1=“Classic” and
Column2=“Image” or Column2=“Gif”

But this will filter only column2 and not column1. If I remove column2 then it will filter column1

Kindly suggest

@Palaniyappan @Yoichi

1 Like

Hi,

Do you mean as the following?

(Column1=“Standard” or Column1=“Classic”) and (Column2=“Image” or Column2=“Gif”)

If so, I suppose perhaps you should use 2 Filter Datatable activties.

1st Filter Datatable activty is for Column1=“Standard” or Column1=“Classic”
2nd Filter Datatable activty is for Column2=“Image” or Column2=“Gif” and input should be the output of 1st datatable activity.

img20200612-2

Regards,

1 Like

What if I have to filter 10 to 15 coumns

I Mean any other way?

Hi,

It’s difficult for single filter datatable activity to handle complex logical expression.
We need to use multiple filter datatable activities, loop like For Each or LINQ.
If we want to use Loop and LINQ , it needs to set filter conditions to collection and/or dictionary in advance.

Regards,

Ok Thank u. One more help. I need to filter the date to previous two days
Now.Adddays(-2).toString(M/dd/yyyy) and format in CSV is *3/14/2000
I am getting zero rows. Anything wrong in my expression

Hi,

Does the data in the csv start with *?
Do you use Contains or EndsWith operation inf the activity?

Not * format which I saw in excel.
If i print dt.Row(0).Item(“columnname”).type it will print string

Hi,

We often face data type problem in datatable filtering.
So I recommend to use LINQ in such case as the following.

dt = dt.AsEnumerable.Where(function(r) DateTime.ParseExact(r("column1").toString,"M/dd/yyyy",nothing)=now.AddDays(-2)).CopyToDataTable()

Can you try above?

Regards,

Its showing not recognised as valid date time

Dt column is in string format I think

Hi,

Can you share your csv file? It’s ok if dummy.

Okay Wait

dummy.zip (143 Bytes)

Please have a look and let me know ASAP

Hi,

Hope the following helps you

Sample20200612-3.zip (10.3 KB)

its showing String is not recongined as valid date time

Hi,

It works good in my environment UiPath 2018.4.7 and 20.4.1CE.
Can you identify which string is invalid?

dt.AsEnumerable.Where(function® DateTime.ParseExact(r(“Start Date”).ToString,“M/dd/yyyy”,nothing)=dateToday ).ToArray()

Here I am geeting exception.
Your project is working fine. If I implement same in my workflow…It shows error

If run my csv file from ur project same error
image

image

image

This is my exact file. I can’t share dat