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.
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
First you need to install UiPath.Excel.Activities package.
search for remove duplicate activity
Hello Vaidya, for me I need the datarows but there are no additional filters to be applied. I have to select unique SSN from the SSN column and write all the datarows corresponding to them in a new sheet. Using your current solution I am unable to do so.
How could this be done? Would really appreciate your help.
dt.AsEnumerable().GroupBy(Function(a) a.Field(Of String)(“name”)).Select(Function(b) b.First).CopyToDataTable()
Try using this, you will get all the distinct column values along with data rows. Then you can apply filters as per your requirement.
What if its a collection list, after adding to collection, we need to remove duplicates. whats the procedure?
Hi, You can use Linq:
Below expiration use the get the distinct Value from DataTable:
dt = dt.AsEnumerable.GroupBy(Function(row) row(“ColumnName”)).Select(Function(row) row.First).CopyToDataTable
.CopyToDataTable() is not reflecting in expression editor.
I hope you might have resolved this already? apologies for replying this late.