Hi everyone. I have a dataset with many columns, and need to remove duplicates based on only a few of them (Below). But I need to keep the duplicate record with the highest value in another column.
My input and desired output are below:
Does anybody have any advice on how to best achieve my desired output? A linq query?
(From d In YourDataTableVar.AsEnumerable()
Group d By k1 = d("Contract").toString.Trim, k2 = d("Order").toString.Trim Into grp=Group
Let grpo = grp.OrderBy(Function (x) CInt(System.Text.RegularExpressions.Regex.Match(x(2).toString, "\d+").Value))
Select r = grpo.Last()).CopyToDataTable
we group on the first 2 cols
order the group members on the number portion from 3rd col
Since I am bringing all of the data in as String, I changed CInt to CStr and it worked flawlessly. Thank you so much for the help and also for the helpful learning links!