Hoping someone has an idea on how to tackle this: My goal is to find only duplicate values in one column of a DT and return their respective values assigned to them.
I hope if anything the screenshot below can better explain.
thank you in advance for your time!
Here you go
hope this expression would help you resolve this
datatable = datatable.AsEnumerable().GroupBy(Function(a) a.Field(of string)(“yourcolumnnname”).ToString).Select(Function(b) b.First()).CopyToDatatable()
Thanks a lot, worked great @Palaniyappan
Hi, what do you mean that worked great? The way i see that expression will just remove the duplicates from the first datatable…
With my data set, it’s ok for me to use .First or .Last since I will only have 1 duplicate at a time and I need perform calculations on these variables separately anyways. So I do two functions, 1st as described above, and 2nd one as below:
datatable.AsEnumerable().GroupBy(Function(a) a.Field(of double)("Code").ToString).Select(Function(b) b.Last()).CopyToDatatable()
ok, no problem, it is just that when marked as solution other people would assume that code will solve their problem, when in truth it wont, although is a good start
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.