Remove Duplicate Rows in a Data Table and Updating of a Column using LINQ

Good day fellow RPA Developers,

I have an INPUT data table dt_Transfer

From this data table, I want to perform the following:

  • If the “Record Type” column of one of the duplicate row(s) has a value of “R” it should be retained. If that “R” column value has a duplicate too, the first row should be returned and update the “Remarks” column to “Reversed”.
  • If the duplicate row(s) has a “O” value on “Record Type” column and it has duplicate row(s), then the first duplicate value should be returned and the “Remarks” should be updated to “Clawback.”
  • If there are no duplicates, the “Remarks” should leave as blank.
    EXPECTED OUTPUT:

How can I implement this in a LINQ?

I already found a solution but it has many filtering and comparing activities using comabination of LINQ and UiPath Datatable Activities.

Refer to this workflow:
RemoveDuplicatewithSpecifiedColumnValue.xaml (24.4 KB)

But if someone has more efficient and more optimized code, please feel free to drop.

Best Regards,
Anthony Jr.

Hi.
If you want to use only Linq, then refer to this.

Remove_Duplicate_Rows_in_a_DataTable_and_Updating.xaml (11.6 KB)

Thank you.

1 Like

This is way more optimized and might be the best solution. Thank @mini319 !

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