cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

How to Compare two Collection variables

Jump to solution

I have two collection variables that looks similar to this:

Collection 1: A, B, C, D, E, F, G

Collection 2: B, D, F, G

Desired Results for Collection 3: A, C, E

In the third collection, I need to have all of the values that are NOT in Collection 2 - comparing the values against Collection 1.

Collection 1 is a complete list of departments. Collection 2 is a list of departments that have submitted a request. Collection 3 should be a list of departments that have NOT submitted a request. 

I know this should be possible and I know i will have to use a Collection Operation. I'm just not sure how to set it up properly. Any help would be AWESOME!

0 Kudos
Reply
9 Replies
Workflow Hero

Re: How to Compare two Collection variables

Jump to solution

nintex doesn't provide action that would operate on whole (multi)sets. you will have to do looping.

for smaller collections (data sets) it might be doable, but for bigger ones you might hit performance issues.

you do not specify how/where do you populate collections from. but it might be much more efficient if you could filter dataset already when reading it in from source.

anyway, to make it with collection, the best would be to use 'remove by value' operation.

- first, determine which collection have less elements

- loop through that collection

- within the loop, 'remove by value' current loop's element/value from bigger collection.

- at the end you should end up with collection of elements that were present in bigger collection but not in smaller one.

Reply
Workflow Hero

Re: How to Compare two Collection variables

Jump to solution

Try this, combine collection 1 and 2 (convert collection 1 and 2 to a string, concantenate , split for semi-colon using regular expression), and use the collection operation remove duplicates.

I haven't tried it, hope it works

0 Kudos
Reply
Workflow Hero

Re: How to Compare two Collection variables

Jump to solution

this is not going to work - 'remove duplicates' removes all but one instances of a given redundant element.

so you will end up with a collection that contains one instance of every element that appeared in either source collection.

0 Kudos
Reply
Workflow Hero

Re: How to Compare two Collection variables

Jump to solution

Use the loop action or the for each action? What would be the conditions for the loop action?

0 Kudos
Reply
Workflow Hero

Re: How to Compare two Collection variables

Jump to solution

ForEach is designed right for iterating through collections.

0 Kudos
Reply
Workflow Hero

Re: How to Compare two Collection variables

Jump to solution

Ya, that's right. But I think regular expression can remove duplicates.

Reply
Workflow Hero

Re: How to Compare two Collection variables

Jump to solution

good idea.

if we assume sorted union of both collections then I think it could be doable with a regex

Reply
Workflow Hero

Re: How to Compare two Collection variables

Jump to solution

I think the best way is to use the "for each" action to iterate it for each value in collection variable 1. Within the "for each" action use a regular expression (check match) if value x of collection variable 1 is part of collection variable 2. The Boolean of the check match action returns the value Yes or No.

Now you can collect all values with Boolean value "no" !

0 Kudos
Reply
Workflow Hero

Re: How to Compare two Collection variables

Jump to solution

Hi ‌,

does any of provided suggestions meets your expectation?

if so, please mark the one correct answer so that the topic is closed.

#BRGreview

0 Kudos
Reply