Filter Data table with the latest item based on date

Hi, I have a data table with the following items.

Column1 Column3
ABC 10-01-2022 17:09:23
FGH 09-01-2022 17:09:23
ABC 10-01-2022 18:09:23

Here, the 1st and 3rd row are duplicates. Is there any way to remove the duplicates based on the date & time? I need to keep the latest one and remove the other one.

But time is different between the mentioned two rows

Yes, time is different. I need to filter duplicates and also keep the latest one. This will keep the first occurrence and remove the remaining duplicates.


For now, can you try to put Remove DataRow activity just before the Assign activity as the following? Please set datatable variable and 0 at each property of the activity.


Hi @manojj.yadav,

If you want to try with Linq check below workflow





(From row In dt.DefaultView.ToTable(True,"Col1").AsEnumerable
Let a = dt.Select("[Col1]='"+row("Col1").ToString+"'").CopyToDataTable
Let b = a.AsEnumerable.OrderByDescending(Function(x) x("Col2").ToString).CopyToDataTable.Rows(0).ItemArray
Select dt2.Clone.Rows.Add(b)).CopyToDataTable


1 Like

The answer for the question can be found here - Filter Excel Record based on Latest date record

Another solution is from - Filter Data table with the latest item based on date - #5 by RajKumar_DC

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