i have an issue where i need to create datatables and then combine them, but then keep only the most recent entry. what i am working on has many more fields than this but shows the probelm
over 3 periods there are 3 sets of sales figures - dt_1, dt_2 and dt_3. what i am trying to get to is dt_final
and as per screenshot dt2 or dt1 does not have remaining dt data…so I dont know how you are saying they are there
but if they are not present and if you know dt1 is first and dt3 is last…just add a new column and give default value as 1,2,3…and instead of date we can use that also by checking the highest nu ber and getting it…for example if an item is there in 1,2,3 then 3 is selected…if present only in1 then 1 is selected…that also can be done
so after a bit of research and some chat-gpt trial and error i got this
create an assign activity for a new dt
DT_Result = (From row In DT_Final.AsEnumerable()
Group row By empID = Convert.ToInt32(row(“Employee ID”)) Into grp = Group
Let maxRunID = grp.Max(Function(r) Convert.ToInt32(r(“Run ID”)))
Select grp.Where(Function(r) Convert.ToInt32(r(“Run ID”)) = maxRunID).First()).CopyToDataTable()
that worked
so @Anil_G thanks for the advice about the date \ counter