Blue Prism Product

last person joined: yesterday 

Chat about Blue Prism products
Expand all | Collapse all

Comparing two Collections to look for unique values

  • 1.  Comparing two Collections to look for unique values

    Posted 08-11-2020 13:32
    Hi all!

    Hoping for some help. I'm quite new to Blue Prism and development in general so I'm a little stuck.

    I'm trying to compare two Collections to determine - Common values in both, Unique Values in Collection 1, and Unique values in Collection 2.

    Then take the comparison and put them into three new Collections

    I have the common values in both by doing a loop within a loop then a decision stage to say [Collection1.Value]=[Collection2.Value]. If yes, Action stage to add row to new collection, then calculation stage to populate that row with [Collection1.Value]

    The trouble comes with the other two sections. I just can't seem to find out the logic for this.

    Is there a way to compare two collections to look for unique values in one of them?

    ------------------------------
    David Wood
    ------------------------------


  • 2.  RE: Comparing two Collections to look for unique values

    Posted 08-11-2020 16:32
    If you're looking for values that are in Collection 1 but not Collection 2, then you could use a loop within a loop and use Remove Row to remove values in Collection 1 as they are encountered in Collection 2 (or vice-versa). 


    If by unique values you mean values that don't repeat themselves within a single collection, you'll need to use a count to keep track of the number of times a value has appeared, then remove values that occur more than once. (Alternatively, one could write a generic code stage to make this easier.)


    ------------------------------
    Nicholas Zejdlik
    RPA Developer
    ------------------------------



  • 3.  RE: Comparing two Collections to look for unique values

    Posted 08-12-2020 04:10
    Hi David - another possibility is to merge the 2 together and then reduce the result down to unique rows - assuming the 2 have the same columns.

    From memory the reduction part is not available in the collection utility, but can be achieved with a not too complicated code stage. In a code stage a BP collection is a .Net DataTable, and you can use that to create a DataView object. The DataView class has a method called ToTable which can filter on unique rows. Obviously you'll need to be comfortable with .Net code to achieve this, but if you are then it's worth investigating whether it will solve your problem.

    ------------------------------
    John Carter
    Professional Services
    Blue Prism
    ------------------------------



Share