Remove duplicates comparing only 2 columns in excel

Hi team ,

I have below data in excel -

I want to remove duplicates where “Quantity” and “Unit Price” have matched . In this case I should only get 2 rows.

Please help in the same.

Attached excel.

Regards,
G
Join_table.xlsx (11.4 KB)

Hi @gokul1904

How about this expression?

(From d In DtRead.AsEnumerable
Group d By k=d("Quantity").toString.Trim, k2=d("Unit Price").ToString.Trim Into grp = Group
Let ra = New Object(){grp.First()(0),grp.First()(1),grp.First()(2),grp.First()(3),grp.First()(4),grp.First()(5),grp.First()(6),grp.First()(7),grp.First()(8),grp.First()(9),grp.First()(10),k,k2,grp.First()(13)}
Select r = DtOutput.Rows.Add(ra)).CopyToDataTable

Check Out the XAML file

DuplicateTwoColumn.xaml (9.1 KB)

Output

Regards
Gokul

hi @gokul1904

Try to use the Remove Duplicates activity from Excel. Thanks

Kind regards,
Kenneth

1 Like

Hi Gokul

I have also attached my code here for your reference.
RemoveDuplicateRows.zip (11.2 KB)

If this resolves your problem kindly mark it as solved. Thank you.

Kind regards,
Kenneth

Hi @gokul1904 ,

Did it work?

Also if your problem is already resolved, don’t forget to mark it as solved it will help others as well. Thanks.

Kind regards,
Kenneth

Thank you!

Please follow these steps: Go to Data tab. Highlight column C to F (since it can’t be done on a multiple range selection. Under Data Tools > Remove Duplicates > select the columns that you want to remove duplicates > OK.

Regards,
Will

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