Remove Dublicate Rows based on a column

I’m a beginner in UiPath and i’m trying to solve this task
I’m trying to remove duplicate rows from an excel sheet based on particular column,
if two rows is duplicated then i have to keep the newest row based on “Transaction time” column,

" * Remove duplicate based on the “Main Transaction” column, the priority is based on the “Start Transaction Time” column. keep the newer transactions."

I need help i cant find a solution

Welcome to the forum

In general we would do it by a groupBy and grouped by 1 col
From the received members we would calculate which one to keep /remove

For GroupBy have a look here:

With some samples provided from your side we can also give more individually help if it is needed

Company_1.xlsx (31.4 KB)
in this excel sheet i need to remove duplicate rows
we can recognize the duplicates by “Main Transaction” column,
the priority is based on the “Start Transaction Time” column we need to keep the newer transactions.

give a try on following

Assign Activity
Leftside: dtResult | DataType: DataTable
Right side:

(From d in YourDataTableVar.AsEnumerable
Group d by k=d("Main Transaction").ToString.Trim into grp=Group
Let go = grp.OrderBy(Function (x) CDate(x("Start Transaction Time").toString.Trim))
Select r=go.Last()).CopyToDataTable

sorry it didn’t work with me :frowning:
can you please provide a .xaml file that can do hte job so i can see it ?
Thanks in advance for the help :slightly_smiling_face:

Here we prefer allways details. What was done? What is not working. Maybe you can share some screenshots from the omplementation details or your XAML with us

Here’s what’s Happening

sorry but Can you please elaborate it more

We would suggest to do the line breaks of the statement as done in example from above
Give another more clear name to variable instead of BuildDataTable
Please show us the variable panel and settings of the origin datatable

Also ensure following:
Group d by k=d(“Main Transaction”).ToString.Trim into grp=Group

ToString instead of String

Hi @Karam_Abulawii

Can you try this linq query with datarow

IEnumerable<DataRow> Transaction =

And loop it through for each item


Hi @Karam_Abulawii

here some videos how to remove duplicates with different methods.
Link 1:
Link 2:

Best regards

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.