How To Remove Duplicates From Datatable In UiPath

Mostly we find duplicates in our excel file/Datatable and it is unavoidable.

In this article we will see how we can find the distinct values. There are many ways to do the same.

Here, we will use the LINQ Query to achieve the result.

dataTable new_dt =
old_dt.AsEnumerable().GroupBy(Function(i) i.Field(Of String)(“columnWithDuplicate”)).Select(Function(g) g.First).CopyToDataTable

The above LINQ query is useful when we are removing duplicates with respect to some “Column” name.


We can use the simple DefaultView Code too…

dataTable new_dt =

It is useful when we are removing duplicates with respect to every “Column”


Implementation using UiPath :

Assume we have a sample data, which includes supplier information.

Step 1:
Drag a “Build Data Table” activity into the design panel.


Step 2:
Populate the “Build Data Table” activity with sample data.


Step 3:
Create a variable of DataTable type with some name and supply it to the Output property of “Build Data Table” activity.


Step 4:
Drag “Assign” activity into the design panel and in the “Value” property of that activity use the above code with proper values


Note: Here we are using the “Supplier Number” column to remove the duplicates from the data table.

Step 5:
Drag “Output Data Table” and “Message Box” activity into the design panel and supply the appropriate parameters to display the data.


Step 6:

Final output!!!


I hope you like the article.

Happy Automation !!