Skip to main content
Nintex Community Menu Bar

How to Compare two Collection variables

  • February 22, 2017
  • 9 replies
  • 120 views

Forum|alt.badge.img+5

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!

9 replies

Forum|alt.badge.img+14
  • Scholar
  • February 22, 2017

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.


Forum|alt.badge.img+10
  • February 23, 2017

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


Forum|alt.badge.img+14
  • Scholar
  • February 23, 2017

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.


Forum|alt.badge.img+5
  • Author
  • February 23, 2017

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


Forum|alt.badge.img+14
  • Scholar
  • February 23, 2017

ForEach is designed right for iterating through collections.


Forum|alt.badge.img+10
  • February 23, 2017

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


Forum|alt.badge.img+14
  • Scholar
  • February 23, 2017

good idea.

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


Forum|alt.badge.img+3
  • April 5, 2017

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" !


Forum|alt.badge.img+14
  • Scholar
  • April 5, 2017

Hi ‌,

does any of provided suggestions meets your expectation?

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

#BRGreview