DataTable filter using "Contains"

Hi,

My source data is an Excel File in where I read the range of the whole sheet and save it in a data table. Sample as below:

image

From the table above, I will filter it by column “Address” and I want to open up a column beside it to write a value that I want to.
Let’s say I filter by (Address “Contains” fine), then the next column it should’ve written “Fine”. Output as below.

image

I will do the filtering by Filter Data Table activity. So whatever under that table I want to write cell in the next column based on my Filter Condition.

How do I go about on this?

Thank you!

Hi @remy223

Welcome back to UiPath Forum.

Please try the below method.

Feel free to reach us at any time if you have doubts. Thanks.

Happy Automation

1 Like

Hi!,

Thank you for the fast reply. Quick question, in the “Write Cell” for the range is it possible for me to put a column name instead of “D”?

No, you can’t able to provide column name instead of range name.

Thanks.

Alright noted. I was actually planning to do filter data table because there are multiple if criteria. The “Fine” could be “fine”, “Fine”, “FINE”, and alterations like that. If I use if condition, can I put in multiple conditions?

Thank you.

Yes, you can give multiple condition in single if activity. Attached screen shot below for your reference.

Thanks.

If you want to give multiple condition in filter activity. Please find the below screen shot.

image

Thanks.

@remy223 - As an alternate …you can just do with one condition

Row(“address”).tostring.toupper.contains(FINE)

Or tolower.contains(fine)

This will first converts your string and check.

Hi @remy223

since u need to do filtering and writing the data under type column , u can try this in invoke code with dt1 as In/out Argument

dt1.AsEnumerable().Where(Function(row) row(“address”).ToString.tolower.Contains(“fine”)).ToList().ForEach(Sub(row) row(“Type”)=“Fine”)

then write the datatable dt1 in an excel file

try and let me know if it works for you

Regards,
Nived N
Happy Automation

1 Like

Hi @remy223

Did it worked for you ?

Hi,

Yes the filter seems to be okay but I am facing issue to open up a column beside to write the value that I want to. Trying to use the write cell method as suggested above currently.

Thank you so much for the assist here!

Hi,

I used the “D”+(idx+1).ToString but instead of writing the output in the next column, it just replaces the value in the same Address column. Any idea where I went wrong?

Thank you!

Hi @remy223

Instead of “D” you can provide the range where you need to write the cell values.

For example: If you need to write the value in F range, then give like below:

“F”+(idx+1).ToString

Thanks.

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