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
------------------------------
1 BEST ANSWER

Helpful Answers

AvinashRamkumar
Level 4

Hi Rinesh,

Using code stages/custom object is easier.
But if your business has restrictions, could try the below method.
1) Create an empty collection (ColB), assume existing collection is ColA
2) Do a nested loop starting with ColA, if row does not exist in ColB, add row to ColB.
3) You can choose whether to delete or retain the copied row in ColA.

Hope this helps.

Thanks,

Avinash



------------------------------
Avinash Ramkumar
------------------------------

View answer in original post

16 REPLIES 16

EmersonF
MVP
@Rinesh Singh,you can be using the action remove duplicates from the collection manipulation, if you don't have this vbo follow the asset link in our DX
Blue Prism Digital Exchange

------------------------------
Emerson Ferreira
Sr Business Analyst
Avanade Brasil
America/Recife
+5581988869544
If my answer helped you? Mark as useful!
------------------------------
Sr Cons at Avanade Brazil

Hi Emerson, 

Thank you for your help!

I have had a look at the package on the link you provided but  it does not make mention of "remove duplicates", The guide for vbo outlines the below as included in this asset.  

Options included in the utility:
• Append Field (Number)
• Append Field (Text)
• Append Rows to Collection
• Collection Contains Field
• Collection Contains Value
• Copy Rows
• Delete Column
• Delete Field
• Field Exists
• Fill Blanks
• Filter Collection
• Get Collection Fields
• Merge Collection
• Read Collection Field
• Remove dots from headers
• Remove Empty Rows
• Remove Null Rows
• Rename Collection Fields
• Rename Field
• Reverse Collection
• Set Collection Field
• Set Column Names From Expected Collection
• Set Column Names From First Row
• Sort Collection
• Split Collection
• Transpose Collection

------------------------------
Rinesh Singh
------------------------------

Try adding a new action to VBO
Write a code stage with this code
Dim pNewDataTable As DataTable
Dim pCurrentRowCopy As DataRow
Dim pColumnList As New List(Of String)
Dim pColumn As DataColumn


For Each pColumn In Input_Col.Columns
	pColumnList.Add(pColumn.ColumnName)
Next

pNewDataTable = Input_Col.DefaultView.ToTable(True, pColumnList.ToArray)

Out_Col = Input_Col.Clone

For Each pCurrentRowCopy In pNewDataTable.Rows
	Out_Col.ImportRow(pCurrentRowCopy)
Next​
And make the following outputs and inputs


Input:
15771.png

Output:
15772.png




------------------------------
Emerson Ferreira
Sr Business Analyst
Avanade Brasil
America/Recife
+5581988869544
If my answer helped you? Mark as useful!
------------------------------
Sr Cons at Avanade Brazil

thanks once again Emerson but unfortunately using code is not an option in our business. Was really hoping for a no code solution.

------------------------------
Rinesh Singh
------------------------------

AvinashRamkumar
Level 4

Hi Rinesh,

Using code stages/custom object is easier.
But if your business has restrictions, could try the below method.
1) Create an empty collection (ColB), assume existing collection is ColA
2) Do a nested loop starting with ColA, if row does not exist in ColB, add row to ColB.
3) You can choose whether to delete or retain the copied row in ColA.

Hope this helps.

Thanks,

Avinash



------------------------------
Avinash Ramkumar
------------------------------

Thanks Avinash, let me try this and will feedback here once I am done.

------------------------------
Rinesh Singh
------------------------------

@EmersonF

i have an error on line 3​ when pasting into code stage, How can i correct it error?

Thank you

15776.png



------------------------------
Jiri Husner
------------------------------

Sorry, I just missed an important part, please do not initialize your object declare the following DLL and Namespaces
15777.png

------------------------------
Emerson Ferreira
Sr Business Analyst
Avanade Brasil
America/Recife
+5581988869544
If my answer helped you? Mark as useful!
------------------------------
Sr Cons at Avanade Brazil

Hi Avinash,
iam getting whole CollA to CollB.

Thanks and Regards,
DevendraNath

------------------------------
Devendra Maganti
------------------------------