Getting Duplicate cases

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

Hi @madhav_raichur

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:

  1. Read range from excel
  2. user filter datatable activity to only keep the rows with name as case.
  3. write range activity to write the filtered datatable to excel

Regards
Sonali

@madhav_raichur

Welcome to the community

Please try this

  1. Read data into datatable dt
  2. Assign with dt = dt.AsEnumerable.GroupBy(function(x) x("case").ToString).Where(function(x) x.Count>1).SelectMany(function(x) x.skip(1)).CopyToDatatable
  3. Write the dt to different sheet which will have all duplicates cases only

Cheers