Power Automate Fundamentals # 6: Usage of Coalesce Function in Power Automate

Introduction:

In Power Automate, most of the common scenario is to verify null values and default to a specific value, in Power Automate it can be achieved easily using Coalesce Function as an example and Plan Object is considered.

Step 1:

Login to the required Power Apps environment using URL make.powerapps.com by providing user name 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 Coalesce to hold Plan Object we must click on + New Step and Choose an operation and in text box type Initialize Variable and select Initialize variable and provide the following

step name as Initialize variable – Plan Object

Name: Plan

Type: Object

Value:

 {

  “name”: “VenkataSubbaraoPolisetty”,

  “plantype”: null,

  “connection”: “landline”

}

  as shown in the below figure.

Step 4:

After Step 3, click on + New Step and Choose an operation  and in text box type Compose  and provide step name as Compose – Coalesce and select inputs and in the below popup select expression and type the following as expression

Coalesce (object_1: any) which returns the first non-null object in the arguments passed in

Example : if plantype is null then false will be defaulted as value otherwise non null value specified in Plan Object , Step 3 will be returned

Usage:

coalesce(variables(‘Plan’)?[‘plantype’],false)

after specify value then click on Ok/Update  as shown in the below figure.

Step 5:

After Step 4, click on Save -> Test -> Manually and click on Test then Run flow .If no errors click on Done and observe the result false will be returned as shown in the below figure.

Step 6:

After Step 5, provide the input object as

Name: Plan

Type: Object

Value:

 {

  “name”: “VenkataSubbaraoPolisetty”,

  “plantype”: true,

  “connection”: “landline”

}

 click on Save -> Test -> Manually and click on Test then Run flow .If no errors click on Done and observe the result  that true will be returned as shown in the below figure.

Note:

  1. Make sure to save and run the flow whenever you try expressions.

Conclusion: In this way one can easily handle null values using Coalesce function in few minutes and use it for required scenarios.

One thought on “Power Automate Fundamentals # 6: Usage of Coalesce Function in Power Automate

  1. Pingback: Rewind August 2021 – 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 )

Google photo

You are commenting using your Google 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