there is an excel that consist of row named case and has multiple data i want to extract the duplicate cases and store in an datatable to store it in excel
Thanks in Adavance
there is an excel that consist of row named case and has multiple data i want to extract the duplicate cases and store in an datatable to store it in excel
Thanks in Adavance
First, Get the duplicate keys (case names)
duplicateKeys = (From row In dtCases.AsEnumerable()
Group row By caseName = row.Field(Of String)("Case") Into grp = Group
Where grp.Count() > 1
Select caseName).ToList()
Then, Get all rows that have those duplicate keys
dtDuplicates = (From row In dtCases.AsEnumerable()
Where duplicateKeys.Contains(row.Field(Of String)("Case"))
Select row).CopyToDataTable()
Hope it helps!!
On getting one dupliacate cases where the sheet as Multiple dubliacate
Hi @madhav_raichur,
You can also consider doing below:
Regards
Sonali
Welcome to the community
Please try this
dt = dt.AsEnumerable.GroupBy(function(x) x("case").ToString).Where(function(x) x.Count>1).SelectMany(function(x) x.skip(1)).CopyToDatatable
Cheers