How to identify duplicate rows based on 3 different columns?

Hi All,

I want to retrieve duplicates based on the columns “Supplier”, “Invoice”, and “Code” in workbook Test.xlsm, remove them from Sheet1, and paste them to Sheet2.

I already know how to remove duplicate rows within a DT using the activity, but that is not the goal.

Example
Input:
image

Expected output:
image

This is what I have so far using Linq, but I didn’t figure out how to group by 3 columns, and I don’t know if there is another way to accomplish this task,

FindDuplicates.zip (81.1 KB)

Currently, it can group by 2 columns but not for 3:
image

Unfortunately, I cannot use non-official activities :frowning:

Regards.

@Tana20 - Please check this

2 Likes

@prasath17 Thanks, it works!

1 Like

This way works well too!
try it.

dt.AsEnumerable()
	.GroupBy(r => (r["Supplier"],r["Code"],r["Invoce"]), r=> r)
	.Where(r => r.Count() == 1)
	.Select(r => r.ToArray()[0])
	//.SelectMany(r => r)
	.CopyToDataTable();
1 Like

@park363 - Have you tried your solution? Lamba expression doesn’t work in Uipath, we have to change it to Function(x) x something like this…

1 Like

upper code is c#.
as your comment, vb uses ‘Function(x) x’ for lambda.

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