cancel
Showing results for 
Search instead for 
Did you mean: 

How to remove duplicate value in collection

RineshSingh
Level 3
Hi there, 

Hope someone can assist with the below please.

I have a collection which contains 2 columns of data. [ID Number] and [Surname]. I would like to remove duplicate ID numbers from this collection and place them into another collection. So i will be left with only unique ID numbers in my original collections.

Does anyone know how I could do this without the use of a code stage.

Thank you

------------------------------
Rinesh Singh
------------------------------
16 REPLIES 16

hello @DevendraMaganti - you are not doing in correct way. Data1 and data2 are two collections.
you need to take reference of column of that collection like Data1.x and check the value in other collection.

P.S - go with code approach. extend your vbo with code stage. That will save the iteration time of collection.


------------------------------
Neeraj Kumar
Technical Architect
------------------------------

Hi Devandra, 

Steps to be followed here is.
1. Take one empty collection assume it Coll B and assuming existing collection is A.
2. Now start loop for Coll A
3. Start Loop for Coll B
4. Compare both collection values , If Yes do nothing, If No copy the coll A value to Coll B
5.Loop Coll B Ends.
6. Loop Coll A Ends.



------------------------------
Aravind Babu
------------------------------

Hi Aravind,

15779.png
Is this the solution u suggested? I did it but it didn't get to the decision stage in the loop. I need to check  duplicates for 2 out of 3 column. Means that the value in column 1 AND column 2 should not have any duplicate in other rows.

Thanks



------------------------------
Nafiz Zainal
------------------------------

Hi Nafiz

Please can you paste the syntax in decision stage

and one more thing is there any restriction in using code stage.

Regards

Lakshmi Narayana



------------------------------
Lakshmi Narayana
------------------------------

Hi @NafizZainal 

Kindly go with the code stage rather than looping the collections as it might take longer iteration time when the collections are fully loaded, as suggested above by @Neeraj Kumar and you can find the code by Emerson Ferreira in the above discussion.

Its a One liner code to be specific ( Collection_Out=Collection_In.DefaultView.ToTable(true) ) , follow this approach if you are facing any difficulties implementing above approaches:

Process : 15784.png

15785.png

Object : Add an Action in one of your existing collection manipulation extended objects or create a new object and check the required Dll and Namespaes in the Initialize page> code options:

15786.png

Add an Action page and add input and output collection and write below code:

15787.png

Collection_Out=Collection_In.DefaultView.ToTable(true)

15788.png



------------------------------
Kindly up vote this as "Best Answer" if it adds value or resolves your query in anyway possible, happy to help.

Regards,

Mukesh Kumar - Senior Automation Developer

NHS England, United Kingdom, GB
------------------------------

Regards,

Mukesh Kumar

Hi Mukesh,

Is this going to work when I need to check only 2 columns with same value out of multiple columns? Here I attached the screenshot:

15791.png

You can see I need to check for duplicate only for column 1 and column 3. What I need to do now is to remove Row 4 from Coll1 and add it into Coll2. Is the code stage possible for this scenario?



------------------------------
Nafiz Zainal
------------------------------

Hi Will this work if the data is duplicates one is in upper case and other in lower case



------------------------------
Vikram Ramesh
------------------------------