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:
|Type||Variable Data Type like Sting, Integer, Float, Array, etc.|
Variable types in Power Automate
Here is a summary of the variable types 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.25, 77.13, etc.|
|String||String data type accepts text values like Power Platforms, Power 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 screenshot below, you can see that the Power Automate different variable types are highlighted.
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:
- 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:
- 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.
- Save the flow, then Select Test-> Manualluy and choose Run Flow as below:
- Once the Flow has been run, we can see the expected output in the compose action with the initialized input variable value.
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.
- 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.
- Next, click on Save and run the Flow manually; once your flow runs successfully
- After the flow ran successfully, we can see that the SharePoint list creates a list item from the array to the list.
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:
Bijay Kumar Sahoo is a highly accomplished professional with over 15 years of experience in the field of SharePoint and related technologies. He has been recognized as a Microsoft MVP (Most Valuable Professional) more than 9 times, starting from April 2014, for his exceptional contributions to the SharePoint community. Bijay is also a prolific author, having written two books on SharePoint – “Microsoft Power Platform – A Deep Dive” and “SharePoint Online Modern Experience Practical Guide“. His deep insights into SharePoint are also shared on his popular YouTube channel EnjoySharePoint where he teaches SharePoint to a global audience (From various countries like the United States of America, Canada, the United Kingdom, Australia, New Zealand, etc). Read more…