UiPath is one of the leading RPA tools now. Working in UiPath Studio is really interesting.
In this article, we will learn about how to use Filter Data Table activity in UiPath Studio.
The Filter Data Table activity helps us to filter a table/DataTable by rows and/or columns. We can either Keep or Remove the desired rows/columns for the output.
In addition to that, we can reposition columns in the DataTable as our wish to represent it in our way. We will see how we can achieve all of these step by step in this article.
Let's begin...
Step 1
Open UiPath Studio
From the Start menu, find Process under New Project column. Click to create a new process.
Write a Name and an optional Description for the process.
Click Create
Step 2
Let's say, we have a table of Employee Data like the image below:
We want to filter only the employees who have their Status as “Part Time”
Let's read the table first.
Take a Read Range Workbook activity from the Activity Panel and configure the activity like the image below:
Give the proper File Path for the excel workbook.
Enter the Sheet Name correctly (Employee_All).
Assign a DataTable variable for the output (DT_All).
Step 3
Now take a Filter Data Table activity from the Activity Panel on the left.
Click on the Configure Filter button. In the Input DataTable field type in the DataTable name we just read from excel (DT_All). For the output of this activity insert a new DataTable variableDT_PartTime
Now, in the Filter Rows tab type in the Column Name or Column Index. As we are comparing String values, choose Operation as Contains. There are different operations available for different purposes but will choose Contains for our filter.
Finally in the Value section type “Part Time” as we want to filter the Part Time employees.
Select Keep button, as we want to keep the rows with our filtered data.
Note
To create variable, click Ctrl+K and give a variable name.
Step 4
Once the filter is configured, we are now ready to see the output.
Take a Write Range Workbook activity from the Activity Panel on the left.
Give the proper File Path for the excel workbook. We can use a new workbook by typing a new name or just use the existing one.
Enter the Sheet Name correctly. Let's write our output in a new sheet named Employee_PT
Assign the DataTable variable (DT_PartTime) for the filtered data to be written from.
Step 5
It’s time to run the project.
Click Run from the Ribbon or click Ctrl+F5
Once the process runs, we now have a new sheet with filtered data with only the Part Time employee info like this:
Step 6
Till this point we have seen one basic DataTable Filter. Now, we will see what else we can do with this activity.
Take another Filter Data Table activity from the Activity Panel and configure the activity like the image below:
Here, for the input DataTable, we will be using the output of our last Filter (DT_PartTime)
In the Filter Rows section, we choose "Salary" column and take Operation as Greater-than (<) and fill out the Value section as 10000
This creates our filter as “any row where the salary is more than 10000”. Now we will click on Remove button. With this, any info of part-time employee who has salary over 10000 will be removed from the DataTable.
The Output Columns tab helps to get only the desired info out of a whole DataTable.
Here, we can use the Column Names or Column Index. Let's say we only need three columns (Employee ID, Salary, Status) from the DataTable, and we want to arrange those columns as we like. Here in this Output Columns tab we just need to add the Column Names or Column Index sequentially and the final output will be prepared accordingly.
Step 7
Once the filter is configured, we are now ready to see the output.
Take a Write Range Workbook activity from the Activity Panel on the left.
Give the proper File Path for the excel workbook. We can use a new workbook by typing a new name or just use the existing one.
Enter the Sheet Name correctly. Let's write our new output in a new sheet named Employee_New
Assign the DataTable variable (DT_FilteredValue) for the filtered data to be written from.
Step 8
Once again it’s time to run the project.
Click Run from the Ribbon or click Ctrl+F5
Once the process runs, we now have a new sheet with filtered data with only the Part-Time employee info with Salary below 10000 (as over 10000 are removed by filter) like this:
Summary
We have read a table of employee info and filtered that by one column value. Now we can try to filter by multiple columns with different Operations.
Also, we have seen how we can rearrange our desired columns in the desired way.
Filter Data Table activity is a simple yet helpful activity. It’s really interesting to work with.
Happy Automation.