How to Initialize A Variable in Power Automate?

In this Power Automate tutorial, I have explained how to initialize a variable in Power Automate. While working with Power Automate, you need to work with variables in Power Automate, and we need to initialize different types of variables.

Variable in Power Automate

A variable in Power Automate temporarily stores 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:

NameVariable Name
TypeVariable Data Type like Sting, Integer, Float, Array, etc.
ValueVariable Value

Variable types in Power Automate

Here is a summary of the variable types in Power Automate.

BooleanBoolean data type accepts the true or false values.
IntegerInteger data type accepts only the numerical data type i.e. 1,2,3 etc
FloatFloat data type accepts decimal numerical values like i.e. 75.2577.13, etc.
StringString data type accepts text values like Power PlatformsPower Automate, etc.
ObjectObject type includes the pair of properties and values in JSON format.
ArrayThe array type contains the list of objects with the same data type.

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

Power Automate initialize variable types

The following will discuss how to initialize variables in a Power Automate flow. In particular, we will see an example of a string variable in Power Automate.

How to Initialize A Variable in Power Automate

Let us see how to initialize a string variable in a Power Automate flow.

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

  • Select the + create flow and click on the Instant cloud flow. Enter the flow name, choose the trigger as Manually trigger a flow, and click on the create option as displayed below:
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 (I have chosen as String), and variable value as highlighted below:
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
  • Save the flow, then Select Test-> Manualluy and choose Run Flow as below:
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

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

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

I will show how to initialize a variable in apply to each in 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 a SharePoint list.

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
  • 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
  • Next, click on Save and run the Flow manually; once your flow runs successfully
Run Power Automate Flow
  • After the flow ran successfully, we can see that the SharePoint list creates a list item from the array to the list.
initialize variable in apply to each action in Power Automate

In this Power Automate tutorial, we discussed what variables are in Power Automate and how to initialize a string variable in Power Automate. And also we saw how to initialize a variable in apply to each in Power Automate.

You may also like: