Power Automate Union Function Explained

Power Automate Union Function

The Power Automate Union function collects all elements of multiple collections and merges them into one collection without duplicate entries.

In case you want to create a collection containing only of elements that are present in both collection, take look at the Power Automate intersection function.

In this article, I’ll introduce you to the union function and will provide a step-by-step guide on how to use the function in a Microsoft flow.

Power Automate Union Function

power automate union expression
union expression in Power Automate

Return a collection containing all elements present in any of the specified collections. If multiple items have the same name, the one that appears last in the input collections will be included in the result.


union('<collection1>', '<collection2>', ...)
union([<collection1>], [<collection2>], ...)

Input parameters

  • collection1 (mandatory): The first collection from where you want all the items in the result.
  • collection2 (mandatory): The second collection from where you want all the items in the result.
  • collection3 ..

Return value

  • Returns a collection: An aggregation that encompasses every item from the designated collections without duplicates.

Power Automate Union Expression Example

Power Automate union two arrays

The most obvious example for the union function is two use it with two arrays:

=> [1,2,3]

Power Automate union distinct

The union function can be used as a distinct function. We only need to pass the collection twice for which we want unique values

// array variable 'myArray' = [1,1,2,2,2,3,3]
=> [1,2,3]

How To Use The Power Automate Union Function

Follow the steps to use the Power Automate Union function in a flow.

  1. Create a new flow with trigger ‘Manually trigger a flow’

    Power Automate Union Function new flow

    New flow

  2. Add a new step by clicking on ‘+ New step’

    Power Automate Union Function new step

    Add a new step

  3. Search for ‘initialize’ and click on ‘Initialize variable’

    Power Automate Union Function initialize variable

    Add Initialize variable action

  4. Setup Initialize variable: 1) Provide a name, 2) select type Array, 3) Set value to ‘[1,2,3]’

    Power Automate Union Function setup initialize variable

    Setup variable

  5. Add a compose step by searching for ‘compose’ and clicking on ‘Compose’

    Power Automate Union Function add compose

    Add Compose action

  6. Setup compose action: 1) click into Inputs (popup appears), 2) click on ‘Expressions’, 3) set expression to ‘union(variables(‘collection1’),createArray(3,4,5))’ 4) click on ‘OK’

    Power Automate Union

    Setup union expression in Power Automate

  7. Save and do a test run

    Power Automate Union Function test run result

    Result test run – Power Automate union function example

Leave a Comment

Your email address will not be published. Required fields are marked *