cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing Collection A Against Collection B

LorenzoCapoccia
Level 4
Hi Team,
I would like to ask for your help,
At the moment I have information from collection A, and I need to compare against collection B to check if values are the same or mismatching,.
I have created a loop start for CollA and then Under Utility collection manipulation, I am using the collection contains value is this the correct one to use?

then on the decision stage I was applying Collection A  = collection B
but I think I am making a mistake, as I am not getting the value confirmation and not reaching the decision, then to allow the Calculation stage to increment the row, so to loop again, and see if there is a mismatch in there, can you please help to find an example data, that I can check against my work?
Thank you
5 REPLIES 5

KaranSareen
Staff
Staff

Hello Lorenzo

If you are trying to compare each value of one collection with each value in the other collection then you can try the following logic i.e. loop within a loop



Using this you can compare values in both the collections

LorenzoCapoccia
Level 4
https://higherlogicdownload.s3.amazonaws.com/BLUEPRISM/UploadedImages/05b2d725-7362-4c3c-9833-f14bac8273e1/current_setup_not_working_as_should.docx

Hi Karan,
I am adding the current set up with each stage screen shot and final screen shot with exception, instead of checking for the 2 mismatch lines...
I think I didn't add the formula correctly, but I cannot see where the error is, or if the formula is ok, I cannot think what I should include in this?
I hope you can help, thank you

PvD_SE
Level 12

Yup, comparing two collections can be a pain. Welcome to BP! 🙂

You could try action Intersection Between Collections that returns the common values between two collections. I haven't used this one, so give it a try. I assume you have to validate the results in some way. Read the help text first, although it holds the same (very low) quality of most of the help texts in BP.
(BP folks: How can it be so hard to write help text for a product? It's not like it is freeware!)

If you only need to establish if they are different, you could start with a row count and columns count on the two collections (Count Rows and Count Columns) and compare if they differ. If there's an amount or other numerical fields, you can total them (Get Field Sum Total) to see if they are equal. Also, you can extract the fields of the two collections (Get Collection Fields) and compare that they have the same fields. If any of this results in a difference, you know they are now identical.

A row-by-row could can be more of a challenge though. I'd sort the collections on the same criteria, then read one collection and the same row for the other, and then compare the two. This will be somewhat of a challenge too I'm afraid. 

Comparing rows between the two collections can be done in a Decision stage as:
[CollA.Field1] = [CollB.Field1]
AND
[CollA.Field2] = [CollB.Field2]
AND
[CollA.Field3] = [CollB.Field3]
AND... 

Or in a more speedy fashion by concatenating each all fields on each row you've read and compare the results between the two:
[CollA.Field1] & [CollA.Field2] & [CollA.Field3]... = [CollB.Field1] & [CollB.Field2] & [CollB.Field3]...

I assume that one of the supported languages for the Code stage such as C# might provide a simpler solution.

----------------
Happy coding! 
Paul
Sweden

Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)

PvD_SE
Level 12
Or the elegant solution in :
https://community.blueprism.com/communities/community-home/digestviewer/view-question?ContributedContentKey=35c50a08-87b9-4ff5-bd25-2ad720c3220d&CommunityKey=3743dbaa-6766-4a4d-b7ed-9a98b6b1dd01&tab=d...
...as provided by Ben Lyons.
Happy coding!
Paul, Sweden
(By all means, do not mark this as the best answer!)

LorenzoCapoccia
Level 4
Thank you very much for your help