What is Initialize Variable in Power Automate

Don’t know What is Initialize Variable in Power Automate and how to use it? This Power Automate tutorial is just for you. Here we will see what is Power Automate to initialize variables and how to work with it.

In addition, we will also see how to initialize variables with dynamic content values with examples and what are the different initialize variable types available in Power Automate flow.

And also we will explore what is Power Automate initialize variable apply to each.

Also, Check: How to Initialize Float Variable in Power Automate

What is Power Automate Initialize Variable

A variable in Power Automate is a temporary storage of the data with different data types such as String, Integer, boolean, float, array, or object.

When we initialize a new variable in Power Automate, we can see the three parameters as explained below:

  1. Name– Variable Name
  2. Type– Variable Data type
  3. Value– Variable Value

Power Automate initialize variable types

Here we will see the various variable data types that are presented while initializing variables in Power Automate.

  • Boolean- Boolean data type accepts the true or false values.
  • Integer – Integer data type accepts only the numerical data type i.e. 1,2,3 etc
  • Float- Float data type accepts decimal numerical values like i.e. 75.2577.13, etc.
  • String-  String data type accepts text values like Power PlatformsPower Automate, etc.
  • Object- Object type includes the pair of properties and values in JSON format.
  • Array- The array type contains the list of objects with the same data type.

In the below screenshot, you can see that the Power Automate different variable types are highlighted.

Power Automate initialize variable types
Power Automate initialize variable types

In the following, we will how to initialize variables in the Power Automate flow, where Recently I got a requirement to work with the SharePoint List and Power Automate.

Read: How to Initialize Object Variable in Power Automate

How to Initialize Variable in Power Automate

Let us see How to Initialize Variable in Power Automate with an example.

So here I have created a SharePoint list called TaskList shown below consisting of different columns called,

  • TaskName(text data type)
  •  Assigned To(Person data type)
  • TaskPriority and Status columns are off (choice data type)
  • StartDate, Due Date, and TaskCompletedDate columns ( Date data type)
  • NumberofDaysToComplete (Integer Data type)
How to Initialize Variables in Power Automate
How to Initialize Variables in Power Automate

To achieve this follow the below steps:

  • Login into the Power Automate flow and then select the + create flow and click on the Automated cloud flow.
  • Enter the flow name and choose the trigger as When an item is created or modified and click on the create option as highlighted below:
How to Initialize Variables in Power Automate example
How to Initialize Variables in Power Automate example
  • Now we will add an action to initialize the variable i.e. initialize the variable. We can able to view the three parameters explained below:
  • Add the dynamic content value in the value section.
  1. Name– Enter the Variable Name
  2. Type– Choose the Variable Data type
  3. Value– Select the dynamic content Variable Value
Power Automate Initialize Variable example
Power Automate Initialize Variable example
  • We will add a Compose action to get the output from the input of the initialized variable.
Example of Power Automate Initialize Variables
Example of Power Automate Initialize Variables
  • Check the flow checker, if the flow has no errors then select the Test option and choose Manually and click Save & Test as highlighted below:
Test Power Automate
Test Power Automate
  • Once the Power Automate flow has been triggered, we can see the expected output from the SharePoint List as below:
Initialize Variable in Power Automate
Initialize Variable in Power Automate

This is how to initialize the variable in the Power Automate flow.

Also, Read: How to Initialize Integer Variable in Power Automate

Example:2

Let us see how to initialize the variable manually by entering the Value of the String data type.

In this example, we will create an instant cloud flow to manually trigger a flow then we will initialize the variable and assign value to the initialized variable.

  • Select the + create flow and click on the Instant cloud flow.
  • Enter the flow name and choose the trigger as Manually trigger a flow and click on the create option as displayed below:
Initialize Variable in Power Automate flow
Initialize Variable in Power Automate flow
  • Once the flow has been created, click the +Add step to add action and initialize the variable in Power Automate.
  • Then enter the variable name, variable type, and variable value as highlighted below:
Initialize Variable in Power Automate flow example
Initialize Variable in Power Automate flow example
  • Now we will add another step to add a compose action to get the output from the initialized input variable value.
  • In the compose action input value, we cannot change the value assigned to the variable.
Example of Initialize Variable in Power Automate
Example of Initialize Variable in Power Automate
  • Save the flow, then Select Test-> Manualluy and choose Run Flow as below:
Run Power Automate Flow
Run Power Automate Flow
  • Once the Flow has been run, we can see the expected output in the compose action with the initialized input variable value.
Example of Initialize Variable in Power Automate flow
Example of Initialize Variable in Power Automate flow

This is how to initialize a variable manually by entering the Value of the String data type.

Power Automate initialize variable in apply to each

Here we will see initialize variable and loop using apply to each section in the Power Automate.

Now we will create a list of arrays in power automate and then add apply to each control action to loop through the array and we will store the array items to the SharePoint list.

So here we will create an Employee list in SharePoint to store the Employee names like below:

Power Automate initialize variable in apply to each
Power Automate initialize variable in apply to each

Create an instant cloud flow, or create a Manually triggered Flow. Then click on the Next step and Select the Initialize variable, set the variable name, choose the type as an array, and add the array values like the below array.

Power Automate initialize variable in apply to each example
Power Automate initialize variable in apply to each example
  • Select Apply to each action to loop each array item. Then in the value set the varArray from the dynamic content.
  • Add an action inside the loop and select Create an item to add an array of items in the SharePoint List
  • Add the site address and SharePoint list name, and in the title select the current item of the Apply to each from the dynamic content.
Example of Power Automate initialize variable in apply to each
Example of Power Automate initialize variable in apply to each
  • Next, click on Save and run the Flow manually, once your flow runs successfully
Run Power Automate Flow
Run Power Automate Flow
  • After the flow ran successfully, we can see SharePoint list creates a list item from the array to the list.
initialize variable in apply to each action in Power Automate
initialize variable in apply to each action in Power Automate

This is how to initialize variable and loops using apply to each section in the Power automate.

In this Power Automate tutorial, we have discussed what is Power Automate to initialize variables. In addition, we also saw how to initialize variables with dynamic content with examples and covered the different initialize variable types available in Power Automate.

And also we learned about what is Power Automate initialize variable in apply to each.

Furthermore, you may like some more Power Automate and SharePoint tutorials: