Hi everyone.
I need help in solving my problem.
let say I have the following data below:

and I only want to keep the last row from timestamp 7/18/2021: 6:41 and delete the remaining entries
how can I do that?
I hope someone can help me
thanks in advance!
Alvin
Yoichi
(Yoichi)
2
Hi,
Can you elaborate meaning about “duplicate”? (Which item is duplicated?)
If you want to extract just last row, thew following will work.
newDt = {dt.AsEnumerable.Last()}.CopyToDataTable()
Regards,
Hi Yoichi,
Thank you for your inputs.
What I mean about the duplicates are the old entries.
In this case I just want to retain the 7/18/2021 6:41 which is the row 3 of the datatable.
thanks
Alvin
Yoichi
(Yoichi)
4
Hi,
if you want to extract the latest record, the following will work.
newDt = {dt.AsEnumerable.OrderBy(Function(r) DateTime.Parse(r("DateTime").ToString)).Last()}.CopyToDataTable()
Sample20210802-2.zip (2.8 KB)
Regards,
Hi Yoichi,
Sorry for the confusion.
let me elaborate more.
let say I have the data set attached
Sample Data.xlsx (8.9 KB)
As you can see there are duplicate entries for abigail.camaya@tdcx.com and anamaysunga@gmail.com
I just want to retain the newest timestamp of each entries
Thanks
Alvin
Is it guaranteed that time stamps will be in Oldest to Newest manner for all the cases ?
Srini84
(Srinivas)
8
@Alvin_Apostol1
Check below query for your reference
dt.AsEnumerable.GroupBy(Function(r ) r(“Email Address”)).Select(Function (g) g.OrderByDescending(Function(r ) Convert.ToDateTime(r(“Timestamp”).ToString))).CopyToDataTable()
Hope this may help you
Thanks
1 Like
Hi Srini84,
I’m getting an error below:

I used the command
WFO_Survey.AsEnumerable.GroupBy(Function (r) r(“Email Address”)).Select(Function (g) g.OrderByDescending(Function(r )Convert.toDateTime(r(“Timestamp”).ToString))).CopyToDataTable()
I’m I doing something wrong?
Please advise
Thanks!
Alvin
Yoichi
(Yoichi)
10
Hi,
Perhaps it will be as the following.
WFO_Survey.AsEnumerable.GroupBy(Function(r) r("Email Address").ToString).Select(Function(g) g.OrderBy(Function(r) DateTime.Parse(r("Timestamp").ToString)).Last).CopyToDataTable()
Regards,
1 Like
Thank you so much Yoichi it worked!
1 Like
system
(system)
Closed
12
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.