Filter Excel Record based on Latest date record

Hot to filter Duplicate record in excel based on Latest Date Hire.

if person number has a duplicated record, i need to filter the Latest Hire Date

image

Thank you in advance

  • Vinent

Hi,

Hope the following sample helps you.

img20211001-2

dt = dt.AsEnumerable.GroupBy(Function(r) r("Person Number").ToString).Select(Function(g) g.OrderBy(Function(r) DateTime.Parse(r("Hire Date").ToString)).Last).CopyToDataTable

Main.xaml (10.3 KB)

Regards,

1 Like

hi @Yoichi

Upon Reading the record,
The headers is unchecked.
image
Because it has a duplicate column in the record

image

so i must read it without header to get the 1st Column (Person Number)
But it thorws me error like this

in_dtRoaster.AsEnumerable.GroupBy(Function(r) r(“Column1”).ToString).Select(Function(g) g.OrderBy(Function(r) DateTime.Parse(r(“Column15”).ToString)).Last).CopyToDataTable

image

Please help
Thank you

Hi,

The above error means “Column15” has invalid DateTime string (or blank). Can you check this?

Regards,

@Yoichi

Yes i checked it already,

image

Hi,

Is there “Hire Date” as data at Rows(0) in Column15? If so, it will cause error because it’s not valid datetime string.

Regards,

How do i solve this?
regards

  • Vincent

Hi,

Quick solution is to remove row#0 using Remove DataRow activity.

Regards,

hi @Yoichi

Can you give me example?

I tried to look for the solution, but this is not exactly what I need.

Hi,

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.

Regards,

1 Like

hi @Yoichi

It works everything now.

Thank you so much for your help

  • Vincent
1 Like

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