How to Use Union Function in Power Automate

How to Use Union Function in Power Automate

Power Automate provides several powerful expression functions for working with arrays and collections. One of the most useful functions is union(), which allows you to combine multiple arrays while automatically removing duplicate values.

The union() function is commonly used for data cleansing, merging collections, generating unique recipient lists, and preparing data for reports and integrations.

What is the Union Function?

The union() function combines two or more arrays and returns only distinct values.

union(
createArray('A','B','C'),
createArray('B','C','D')
)

Output:

['A','B','C','D']

Remove Duplicate Values

A common technique is using the same array twice inside union() to remove duplicates.

union(
variables('ProductList'),
variables('ProductList')
)

The output contains only unique values from the ProductList array.

Merge Dynamic Arrays

You can merge arrays retrieved from SharePoint, Dataverse, Excel, APIs, or other connectors.

union(
variables('DepartmentArray1'),
variables('DepartmentArray2')
)

This creates a single collection containing unique values from both arrays.

Combine Multiple Arrays

The union() function supports more than two arrays.

union(
variables('Array1'),
variables('Array2'),
variables('Array3')
)

The output contains unique values from all provided arrays.

Important: The union() function automatically removes duplicate values and returns only distinct items. All inputs must be arrays.

Common Business Scenarios

Benefits of Using Union()

Best Practices

Key Takeaways