Filter datatables and Keep duplicates

How can I filter a data table using the reference method to retain duplicate data in a specific column?
I mean, I want to retain duplicates.

Hello @alexis.mendoza.rpa

use assign activity

dtOutput=(From row In dtInput.AsEnumerable()
Group row By key=row(“ColumnName”).ToString.Trim Into grp=Group Where grp.Count() > 1 From r In grp
Select r).CopyToDataTable()

Use this query It will work

Regards,
Rajesh Rane

@alexis.mendoza.rpa,

By default Filtering the data will retain all data along with duplicates. Just use Filter Data table activity and apply the filter on the desired column.

Hi @alexis.mendoza.rpa

Use the Filter Data Table activity on dt with the condition “IsDuplicate” equals True and store the result in a new DataTable called dtDuplicates.

If helpful, mark as solution. Happy automation with UiPath

I can’t find the option you mentioned.

Not like that , we cant use directly.
try like add a new column "IsDuplicate" as a String to your DataTable. Loop through each row and count how many times its value appears in the target column. If the count is more than one, set "IsDuplicate" to "True", otherwise "False". Then use the Filter Data Table activity to keep only rows where "IsDuplicate" equals "True".

Happy Automation

It doesn’t work, I get the following error

Could you show me how? I can’t see it well.