Dt1:
Dt2:
There will be multiple dates for each user in dt2 datatable for each user.
How to get only the latest date (Highlighted in Green) for each users from dt2 and update in the “Date of Last Locking” column in dt1 in the respective user row
Dt1:
Dt2:
There will be multiple dates for each user in dt2 datatable for each user.
How to get only the latest date (Highlighted in Green) for each users from dt2 and update in the “Date of Last Locking” column in dt1 in the respective user row
Please follow the steps
dt2 = dt2.AsEnumerable.OrderByDescending(function(x) Cdate(x("Date").ToString)).CopyToDataTable
"User" equals currentrow("User").ToString
and save in filtereddt tablecurrentrow("Date of Last locking") = filtereddt.Rows(0)("Date").ToString
to get latest dateHope this helps
Cheers
Hi @Sathish_Kumar_S ,
Can you share a sample file? So that we can check on.
Hi @Sathish_Kumar_S ,
An alternate way :
GroupedDT = DT2.AsEnumerable.GroupBy(Function(x)x("User").ToString).Select(Function(x)x.OrderByDescending(Function(y)CDate(y("Date").ToString)).First).CopyToDatatable
Here, GroupedDT
is a variable of type Datatable which contains the Users with their Latest dates, DT2
is your Input DT2.
Next, we can use Join Datatables
Actviity with the First datatable as DT1 and Second Datatable as GroupedDT
. Join Type as Left Join
. The column to match should be entered as "User"
.
The data from the GroupedDT
should be concatenated with the matching rows with the DT1 data rows.
The above would not update the column Date of Last Locking
but we can rename the column Date_1
in the resultant datatable to ‘Date of Last Locking’ using the below Expression in an Assign
Activity.
DT1.Columns("Date_1").ColumnName = "Date of Last Locking"
Let us know if you were able to implement this method or facing any issues.