How to get values from data table and input those value as filter conditions?

Hi everyone, I’m filtering an excel file by month and some conditions.
Now, I write all conditions like this:

But I would like to make a more flexible workflow. Let the robot can read the data table below and get those values one by one. Finally, the robot can filter the excel file by those values and output the data table that I want.

Please guide if anyone knows.


Welcome to uipath community
Hope these steps would help you resolve this
—use a excel application scope and pass the file path as input input
—inside the scope use a read range activity and get the output with a variable of type datatable named dt
—now use a assign activity like this
arr_values = Split(dt.Rows(0)(“Value”).ToString,”,”)

Where 0 is the row index of first row and value is the column name from where we are trying to get the value A,B,C,D,E

Now this arr_values will have that array of elements
—use a FOR EACH activity and pass the. Above variable arr_values as input and change the type argument as string in the property panel
—inside the loop use the assign activity and with same expression you have used for SELECT METHOD
But replace the variable of Profit ctr with item.ToString so that for the first iteration of value the first value will be passed as input and we will be getting the related data as datatable

Kindly try this and let know for any queries or clarification
Cheers @WWM

1 Like

Hi! @Palaniyappan
Thanks for your reply. It’s so helpful!
But I have two more questions now…Please see my .xaml file as attachment.
Config.xlsx (9.4 KB) FilterTemplate.xaml (20.5 KB) InitAllSettings.xaml (14.5 KB) Test.xlsx (10.5 KB)
Question 1:
I get the value A,B,C,D,E as the array elements. But there is no “D” in the column which I want to filter. In this situation, an error occurs and system logs a message: source contains no DataRows.
I tried to use Trycatch activity to resolve this error, but it did’t work. Can you teach me how to fix it? Thanks

Question 2:
Now I filter only one column named “Profit Ctr” by for each activity, If I want to add a condition to filter another column named “Cost Ctr”. the only way is assign “arr_values 2” and use a for each activity to filter the data table which I have filtered by “Profit Ctr”?

If you have any suggestions, please let me know.
Many thanks,

I resolved Question 1 by myself.
Anyone knows how to deal with Question 2 ?

1 Like

May I know the issue we are facing here
The syntax is correct
Cheers @WWM

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