cancel
Showing results for 
Search instead for 
Did you mean: 

Remove duplicates from collection based on specific column

GuggsKia
Level 4
Hello Community, 
I have a collection, suppose Col1. It has 2 columns i.e. Operating System and UserId.
I need to filter out the rows in Col1 with its name as Linux and Mac. But before it filters both I want to remove duplicates if any.
Operating System UserId 
Mac.                          123
Mac.                          123
Linux.                        652
Mac.                          124
First thing, two seperate collections for Linux and Mac.
Second thing, removing duplicates based on UserId. 
Note:one userId can have multiple OS.

------------------------------
Guggs Kia
------------------------------
2 REPLIES 2

Hi,

There are some assets available on DX which can cater to these scenarios. I haven't tried this myself but here are the links -

https://digitalexchange.blueprism.com/dx/entry/78038/solution/spgmi--utility-collection-booster
https://digitalexchange.blueprism.com/dx/entry/35840/solution/millicon---collection-utility


------------------------------
Shashank Kumar
DX Integrations Partner Consultant
Blue Prism
Singapore
+6581326707
------------------------------

jebarson
Level 3
Use the following code to remove duplicate names based on column names.

[Inputs : coll,collName ]
[Output: groups ]

Dim hTable As New Hashtable()
Dim duplicateList As New ArrayList()


'Add list of all the unique item value to hashtable, which stores combination of key, value pair.
'And add duplicate item value in arraylist.

For Each drow_1 As DataRow In coll.Rows

If hTable.Contains(drow_1(colName)) Then

duplicateList.Add(drow_1)

Else

hTable.Add(drow_1(colName), String.Empty)

End If

Next



'Removing a list of duplicate items from datatable.

For Each dRow_2 As DataRow In duplicateList

coll.Rows.Remove(dRow_2)

Next



groups = coll

------------------------------
Jane Jebarson Senior Automation Engineer
Engineer
Allianz
Europe/London
------------------------------