Remove All Duplicate Rows

Hi Team,
I have a data table
Acc No - Name
111 - aaa
222 - bbb
333 - ccc
444 - aaa

Bot should remove the duplicat row aaa. I tried with - remove duplicate row activity but not working.

Hi @Robotics

Try with this expression

(From p in DT.Select() where( From q in DT.Select() where q("Column name").Equals(p("Column name")) Select q).ToArray.Count=1 Select p).ToArray.CopyToDataTable()

Regards
Gokul

Removing ALL aaa / duplicates

Assign Activity:
dtCleansed =

(From d in YourDataTableVar.AsEnumerable
Group d by k=d("Name").toString.Trim into grp=Group
Where grp.Count = 1
Select r = grp.First()).CopyToDataTable

Removing / keep distincts by using taking first from duplicates

Assign Activity:
dtCleansed =

(From d in YourDataTableVar.AsEnumerable
Group d by k=d("Name").toString.Trim into grp=Group
Select r = grp.First()).CopyToDataTable

Hello @Robotics

Please check the below post.

dataTable new_dt =
old_dt.DefaultView.ToTable(True)

Thanks

Check out the XAML file @Robotics

RemoveDuplicateRows.xaml (7.2 KB)

image

Output

image

Regards
Gokul

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