Distinct values in a datatable

datatable

#1

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.


#2

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

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.


#3

I need the datarows that are filtered on a particular column


#4

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")