How to Initialize Variable Condition using Power Automate

In this Power Automate tutorial, we will learn How to Initialize Variable Condition using Power Automate with a few examples. And also, we will cover the below-related headings.

  • Power Automate initialize variable inside condition
  • Power Automate initialize variable after condition

Also, Read: How to Set Variable Based on Condition in Power Automate

Initialize Variable Condition using Power Automate

Let us see how to work with Power Automate initialize variable condition.

Recently, I was working with a requirement where I needed to apply the condition to track the Assigned Task Status. For this purpose, I have used Power Automate and SharePoint List. Follow the below steps to understand it clearly.

How to Initialize Variables in Power Automate
How to Initialize Variables in Power Automate

To achieve this Follow the below-illustrated steps:

Step:1

  • Initially, log in to Power Automate flow using the credentials, and select +Create -> Automated cloud flow.
  • Enter the flow name Choose the trigger when an item is created or modified and click on the create option as highlighted below:
Power Automate initialize variable in condition
Power Automate initialize variable in condition

Step:2

Configure the trigger with the SharePoint Site Address and List Name here I have selected my SharePoint site and the SharePoint list Name (TaskList).

Power Automate Initialize Variable with Condition
Power Automate Initialize Variable with Condition

Step:3

  • Select plus sign (+New Step)-> Add an action to initialize variable for the task Status column to track the status of the assigned tasks.
  • Enter the variable name as TaskStatus Value and choose the data type as a string and add dynamic content value of Status Value in the value section.
Power Automate initialize variable in condition example
Power Automate initialize variable in condition example

Step:4

  • Click on the Next step and select condition control action, to track the status value for the assigned tasks.
  • If the Task status is Completed or In-Progress then in the compose action we will display The Assigned task as either in the completed or In-Progress status. Else, if it is blank or On-Hold status then in the compose action we will display The Assigned task in On-Hold status.
Example of Power Automate initialize variable in condition
Example of Power Automate initialize variable in condition

Step:5

 Select Test-> Manually-> Save & Test to save and test the Power Automate flow.

Test Power Automate
Test Power Automate

Step:6

Here we will modify an existing item in the SharePoint list to trigger the Power Automate flow, where the Task Status Value is the In-Progress value as below:

Example of Power Automate initialize the variable condition
Example of Power Automate initialize the variable condition

In the below screenshot, we can see that the compose action displays the expected output based on the condition applied.

Power Automate initialize variable condition example
Power Automate initialize variable condition example

In the same way, we will modify an existing item in the SharePoint list, where the Task status value contains a blank or empty value.

Initialize Variable Power Automate flow example
Initialize Variable Power Automate flow example

The Screenshot below displays the result in compose action based on the condition applied.

Power Automate initialize a variable condition example
Power Automate initialize variable condition example

This is how to Initialize the variable in Condition in Power Automate flow or Microsoft flow.

Check out: How to Work With Set Variable Action in Power Automate [With Examples]

Power Automate initialize variable inside Condition

  • No, it is not possible to initialize variable inside the Condition action in Power Automate.
  • Because in the Power Automate condition action, we can only see If Yes and If No options. So it is not impossible to initialize variable inside the condition action.
  • There is no default option to add an action inside the condition action in Power Automate flow.
Power Automate initialize variable inside the condition

Power Automate initialize variable after condition

Let us see how we can initialize the variable after the condition action in Power Automate.

  • It is possible to initialize variable after the condition action, but it is not possible to use the initialized variable in the Previous step. If we use it, then the error occurs.
  • If we want to use the initialized variable in the condition action, then we have to initialize it before the condition action step.

Here you can see I have initialized the variable after the condition action step:

Power Automate initialize variable after condition
Power Automate initialize variable after condition
  • To save and test the Power Automate flow Select Test-> Manually-> Save & Test.
  • In the below screenshot, you can see the flow run has failed because of the wrongly initialized variable.
Power Automate initialize variable after condition example
Power Automate initialize variable after condition example

So it is impossible to initialize variable after the condition action and use the initialized variable in the prior step in the Power Automate flow.

In this Power Automate tutorial, we have learned How to Initialize Variable Condition using Power Automate with a few examples. with examples. And also we covered the below-related headings.

  • Power Automate initialize variable inside condition
  • Power Automate initialize variable after condition

Additionally, you may like some more Power Automate tutorials: