Skip duplicate row in each

Hello all,

The last time I do as this it oki, but now I don’t know it not skip duplicate row in each at D column ?
image

@anh.nguyen

Please try using the condition like this

Prevdev.Contains(currentrow(3).ToString.Trim)

And on then side you have duplicates and on else side you have unique.and on else side add a assign activity as below

prevdev = prevdev + currentrow(3).ToString.Trim

And initialize prevdev = string.Empty outside the loop

This way it will add all the items which are already found and check them

Cheers

1 Like

@anh.nguyen
The DefaultView property returns a DataView you can use to sort, filter, and search a DataTable.

For Example :We can use the simple DefaultView Code to To Remove Duplicates From Datatable In UiPath

dataTable new_dt =
old_dt.DefaultView.ToTable(True)

Note:
Useful when we are removing duplicates with respect to every “Column”

1 Like

Hi @anh.nguyen ,

I believe you are using a Loop and inside it you have placed the code in the Screenshot, If that is the case, I believe you would require to keep the Assignment of preDLV variable to Empty string outside the Loop.

We do not have the full view of the Implementation, hence we can only help out on Trial and Error methods. This would also require your datatable to be sorted based on the Column you are trying to detect duplicates (DLV column).

Let us know if you were able to correct the approach.

1 Like

Thank you so much. I added preDLV <> Currentrow(3).ToString.Trim

It run oki. Thank all

1 Like

@anh.nguyen
yourDT.DefaultView.ToTable(true, “ColumnName”)

We can get the Distinct Value from a Column of a Datatable using the Distinct() method.

However, we need to note that if there are more than two different values we get two distinct values as the output.

Could you try with the below Expression and Let us know if it is the Output that was Expected :

DT.AsEnumerable.Select(Function(x)x("Ticket Value").ToString).Distinct.First