Remove duplicate based on a condition

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