Remove duplicate based on a condition

Hi,

I have large set of Datatable and i want to remove duplicate rows. however it is based on Date (condition).
Filter.xlsx (8.8 KB)

Can some one please help me?

Hi,

Can you try the following sample?

img20220125-8

dt = dt.AsEnumerable.GroupBy(Function(r) r("A").ToString).Select(Function(g) g.First).CopyToDataTable()

Sampe20220125-5.zip (8.7 KB)

Or if you need to keep the oldest row, the following is better.

dt = dt.AsEnumerable.GroupBy(Function(r) r("A").ToString).Select(Function(g) g.OrderBy(Function(r) DateTime.Parse(r("C").ToString)).First).CopyToDataTable()

Regards,

2 Likes

Thanks a lot for perfect solution :slight_smile:

1 Like

Hi,

For this can we use Delete Rows Activity or Remove Duplicate Rows Activity as well.

Thanks in advance.

We can but i was looking for a solution where I had a condition on date. I need to keep the first date

Got it. Thanks.

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