Power Automate Fundamentals # 54: Usage of Intersection Function in Power Automate

Introduction:

In Power Platform, at times we must take common values present in Arrays or objects. In these scenarios, Intersection function in Power Automate can be used. As an example, Names Array and Names Object and Actual Names Array,Actual Names Objects were used to explain this behaviour.

Step 1:                                                                                                                            

Login to the required Power Apps environment using URL make.powerapps.com by providing username and password and click on Flows on the left-hand side as shown in the below figure.

Step 2:

After Step 1, Click on New Flow and select instant cloud flow and provide the trigger as Manually trigger a flow and click on Create as shown in the below figure.

Step 3:

After Step 2, name the flow as Intersection Function and take a parallel branch and one side of branch take an initialize variable and name it as Names Array and provide values

Name: Names Array

Type: Array

Value: [“Venkata”,”Polisetty”,”Subbarao”]

as shown in the below figure.

Step 4:

After Step 3, to the other side of  parallel branch take another initialize variable and name it as Names Object and provide values

Name: Names Object

Type: Object

Value: {

 “name1″:”Venkata”,

 “name2”: “Polisetty”,

 “name3”: “Subbarao”

}

as shown in the below figure.

Step 5:

After Step 4, under Names Array take another Initialize variable and name it as  Actual Names Array and provide the inputs as

Name: Actual Names Array

Type: Array

Value: [“Venkata”,”Polisetty”,”Subbarao”]

as shown in the below figure.

Step 6:

After Step 5, under Actual Names Array take another initialize variable and name it as Wrong Names Array and provide the inputs as

Name: Wrong Names Array

Type: Array

Value: [“Venkata”,”Polisetty”,”Rocky”]

in the below figure.

Step 7:

After Step 6, under Wrong Names Array ,take compose action and name it as Are Names Matching between Names Array and Actual Names Array and intersection function Returns a single array or object that has common elements between arrays or objects passed in. The parameters for the function can either be a set of objects or a set of arrays (not a mixture of both). If there are two objects with the same name, the last object with that name appears in the final object with the following syntax as

intersection(collection_1: object|array, collection_2: object|array)

and provide the input as

intersection(variables(‘Names Array’),variables(‘Actual Names Array’))

in the below figure.

Step 8:

After Step 7,under Are Names Matching between Names Array and Actual Names Array take compose action and name it as Are Names Matching between Names Array and Wrong Names Array and provide the value as

intersection(variables(‘Names Array’),variables(‘Wrong Names Array’))

in the below figure.

Step 9:

After Step 8, under Names Object take another Initialize variable and name it as  Actual Names Object and provide the inputs as

Name: Actual Names Object

Type: Object

Value: {

 “name1″:”Venkata”,

 “name2”: “Polisetty”,

 “name3”: “Subbarao”

}

as shown in the below figure.

Step 10:

After Step 9, under Actual Names Object take another Initialize variable and name it as  Wrong Names Object and provide the inputs as

Name: Wrong Names Object

Type: Object

Value: {

 “name1″:”Venkata”,

 “name2”: “Polisetty”,

 “name3”: “Rocky”

}

as shown in the below figure.

Step 11:

After Step 10, under Wrong Names Object take compose action and name it as  Are Names Matching between Names Object and Actual Names Object and provide the inputs as

Inputs: intersection(variables(‘Names Object’),variables(‘Actual Names Object’))

as shown in the below figure.

Step 12:

After Step 11, under Are Names Matching between Names Object and Actual Names Objecttake compose action and name it as Are Names Matching between Names Object and Wrong Names Object  and provide the inputs as

Inputs: intersection(variables(‘Names Object’),variables(‘Wrong Names Object’))

as shown in the below figure.

Step 13:

After Step 12,save and test the flow and observe the results as shown in the below figure.

Note:

  1. Make sure to save and run the flow whenever you try expressions.
  2. Make sure to provide input array in proper acceptable format of string array.
  3. Also use double quotes for the elements in the array.
  4. Intersection will work on like objects/arrays.
  5. For object , make sure to frame it as json object.

Conclusion: In this way we can use Intersection function in power automate to achieve customer functionality.

One thought on “Power Automate Fundamentals # 54: Usage of Intersection Function in Power Automate

  1. Pingback: Rewind February 2022 – Common Man Tips for Power Platform, Dynamics CRM,Azure

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s