How to get value based latest date?


I have a data like this and with my expected output :


I tried to do in query with MAX(DATES) function but it’s not working… In UiPath, it will only get 1 value only. If I have 1000 data like this, how to get the value based on latest date? Thanks :slight_smile:

Here is the excel file :

Dummy.xlsx (9.0 KB)

you can use sort Data table
please follow this workflow
Sample2.xaml (9.4 KB)


It’s as expected, but what if I have 10.000 data that are needed to be sorted like this? Because I also have to remove the unnecessary dates (in picture, 2 june and 13 june need to be removed to avoid redundant data)


Hope the following helps you.

dt = dt.AsEnumerable.GroupBy(Function(r) DateTIme.Parse(r("Sent Date").Tostring)).OrderBy(Function(g) g.Key).Last().CopyToDataTable() (8.8 KB)



I tried your solution and it works only for 1 customer ID, I tested with 3 customer ID like this :

And it only returns 1 value instead of 3.

Here is the file :

Dummy.xlsx (9.5 KB)


How about the following?

dt = dt.AsEnumerable.GroupBy(Function(r) r("Customer ID").ToString).SelectMany(Function(g) g.GroupBy(Function(r) DateTIme.Parse(r("Sent Date").Tostring)).OrderBy(Function(g2) g2.Key).Last()).CopyToDataTable() (16.0 KB)


1 Like

Working as expected. Thank you very much Mr. Yoichi !!

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