How to Get Unique Values from an Array in Power Automate?

Are you in need of getting unique values from an array using flow? Then, this Power Automate tutorial will help you get unique values from an array in Power Automate.

Scenario:

While working on Product development, I need to get unique values from an array to remove duplicates presented in an array using the Power Automate flow. For example, If my array looks like the below:

[1,2,1,3,1,4,2,5,2,3,5,6]

Once I remove all the duplicate values presented in an array, My array should contain unique values as below:

[1,2,3,4,5,6]

Now, we will see how to get unique values from an array in Power Automate.

How to Get Unique Values from an Array in Power Automate

Let us see how to get unique values from an array using flow,

Example-1:

Step-1:

Create an instant cloud flow with a manual trigger, add a new step, select an initialize variable action with the array data type, and provide the below parameters.

  • Name – Enter the variable name
  • Type – Choose the variable type as array
  • Value – pass the below code, which creates an array of values
createArray('1','1','2','3','4','5','4')
get unique values from array in power automate

Step-2:

To remove duplicates and get the unique value, we are going to use the union()function which returns only the unique values

union(variables('VarNumbers'),variables('VarNumbers'))
get unique values from array in power automate flow

Step-3:

Save and run the flow; once the flow runs successfully, we can see it returns only the unique values from an array using flow.

How to get unique values from array in power automate

This is how to get unique values from an array using flow.

See also  How to disable Power Apps date picker

Example-2:

In this example, I’ll show you how to get the unique values of the Product Name field presented in the SharePoint list.

Here, I am going to use the below SharePoint list of columns:

Column NameColumn Type
Product Namedefault title column
Product IDText column
ProductPriceNumber column
How to get unique values from array in power automate flow

Step-1:

Create an instant cloud flow with a manual trigger, add a new step, select an initialize variable action with the array data type, and provide the below parameters.

  • Name – Enter the variable name
  • Type – Choose the variable type as array
get unique values from array using power automate flow

Step-2:

  • Select the +new step and add the Get items to trigger action from the action triggers.
  • Configure the SharePoint site address and list name.
get unique values from array using power automate

Step-3:

Add a new step and choose Append to array variable action; in the Name, select the initialized variable, and in the value section, pass the Title from the dynamic content value

how to get unique values from array using power automate

Step-4:

Add a compose data operation to remove duplicates and get the unique value of the ProductName presented in the SharePoint list; use the below expression

union(variables('Products'),variables('Products'))
how to get unique values from array using power automate flow

Step-5:

save and run the flow by selecting the run flow option; once the flow runs successfully, it removes the duplicates of the ProductName field presented in the SharePoint list and returns only the unique value of the product names.

In the Product Name field, it removes the duplicate values and displays the outputs in the compose data operation.

get unique values from an array using power automate flow

This is how to get unique values from an array in Power Automate.

Conclusion

I hope you got an idea to get unique values from an array using Power Automate.

See also  Create Login Page in PowerApps using SharePoint List

Here, I have shown you two different examples of getting unique values from an array by using the union() function in Power Automate.

You may also like:

>