Find Duplicate based on one column and change value of another column

Hello,
I have a case to find duplicate in data table like this :
image
I want to change the value of other column at first row has duplicate like this :
image

I’m sorry if i am not good in english. so maybe any idea to solve this case

Thank you!

1 Like

try this
Sequence1.xaml (15.8 KB)

before
image

after
image

logic

  1. append rowNumber column to dt
  2. get uniqueNameList
  3. loop uniqueNamelist
    for each unique name:
  • filter dt to dtNew where [Name] = name
  • if dtNew row count > 1, assign
    dt.Rows(cint(dtNew.Rows(0)("RowNumber")))("Status") = Active (Duplicate)

Hey @mr_Fajar_28

You wanna find duplicates based on which column please ?

Thanks
#nK

Hi,

FYI, another solution:

dtResult = dt.AsEnumerable.Select(Function(r) dt.Clone.LoadDataRow(if(dt.AsEnumerable.Count(Function(r2) DataRowComparer.Default.Equals(r,r2))>1 AndAlso dt.AsEnumerable.Take(dt.Rows.IndexOf(r)+1).Count(Function(r2) DataRowComparer.Default.Equals(r,r2))=1 ,r.ItemArray.Take(2).Concat({r(2).ToString+"(Duplicate)"}).ToArray,r.ItemArray),False)).CopyToDataTable

Main.xaml (8.2 KB)

Regards,

Column name

Thank you @Yoichi and @jack.chan for giving idea to solve this case

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.