Distinct values in a datatable



Can anyone help me with code in uipath to get the distinct values in a datatable based on a particular column.

Detailed explanation of query:
I had a datatable which has around 8 columns and multiple rows i need to filter the datatable based on a date column with highest date then i need to get the distinct rows based on one column.

If any one suggests with some sample xaml code that would be great.

Remove Duplicate Entries with exception of the first one


This will return a new datatable having only one column and distinct values of that column from the original table.

You can then iterate over this new datatable and in each iterationn use the datatable.select method for accessing only those rows where the distinct value matches.


I need the datarows that are filtered on a particular column


I will go with @akhi_s27’s solution but other way around.

first do a Datatable select

copyDataTable = dt.Select("Date= MAX(Date)").CopyToDataTable();

then get distinct values

copyDataTable .DefaultView.ToTable(True,"ColumnName")