I’m facing a problems in deleting duplicates from a DataTable. I already tried deleting them using REMOVE DUPLICATES activity, from both Excel and DataTable activities but, for my problem, it did not worked. Here is a screenshot of my workflow:
The condicional verifies if the list ‘duplicatesList’ contains the value of the current row, and if it does, the row is added to another list, to be iterated later, removing from the original DataTable, but I can’t find a way to use this list with the data table.
willing to help provinding more info.
Try with this linq query to delete rows of a column if that column doesn’t have any of the values form the list variable
filteredDataTable = originalDataTable.AsEnumerable().Where(Function(row) yourList.Contains(row("ColumnName"))).CopyToDataTable()
Could you let us know if you would want to correct your existing approach or if you are open for other approaches as well ?
If open for other approaches, there are already many scenarios/posts here on removing duplicate rows available, Could you maybe check on them, One of them is below :
This can be done as follows
Instead of Build Data Table activity use the Read Range Activity to read the input excel file into the data table variable (inputDT)
The LINQ used is given below
From row In inputDT
Group row By
k1 = row("FIRST NAME").ToString.Trim,
k2 = row("SURNAME").ToString.Trim,
k3 = row("POLICY NO").ToString.Trim,
k4 = row("START DATE").ToString.Trim
Into grp = Group
Finally you can write the output in an excel file…
Let us know if you were able to perform the same operation or need help in modifying it.
Had to add the ‘ToString’ cause was returning that i can’t convert an object to string. Is it right?
Basically that’s right
As we are comparing with list or array of string we are converting to string
it’s returning this error…
May be something related to the type of the strings?