Here’s how you can use Environment Variables in Power Automate!

we will learn about variables, data types, creating variables, and how to perform operations and actions on them. We can send a list of products in one email with the help of variables. Variables are temporary storage inside Microsoft Power Automate flow where we can have a storage of data in which we can keep the content, numbers, strings, etc.

Data types of variables

Boolean : In this data type the values can be True or False.

Integer : It accepts a numeric value which should be a whole number. (eg: 4,2,8)

Float : It accepts a numeric value that can be decimal. (eg: 123.5, 2.67)

String : It accepts text input values. (eg: Hello, Microsoft)

Object : It contains pairs of properties and values, which are in JSON (JavaScript Object Notation) format.

Array : It is used to input a list of objects which can be a number or string that have the same data type.

Creating Variables

Let’s go to our Microsoft Power Automate.

Click on Create from the left-hand side panel. Select Instant cloud flow.

Give a name to the flow and select Manually trigger a flow

 Click on Create Click on the new step to add Variables.

  

We need to create a variable. Select Initialize Variable from actions.

Enter Name for your variable. Select the data type of your variable.

Assign the Value to the variable and click on the New step.

Select the Compose Action, we could only get the result from the value input, but we can’t change the Input, which means there is no way to modify the original input of the same compose.

 

Add Input as My Age variable from Add dynamic context. Click Save.

Now, test and Run Flow  by Manually triggering it.

After running the flow. We can the Output in Compose.

Performing Operations On Variables

We can perform operations like set, Increment/Decrement and Append on variables.

Click on the arrow between Initialize Variable and compose. Click on Add an Action.

Select Set Variable from actions.

Select the previous variable My Age and add Value to it.

Test and Run flow Now click on Compose Now the variable value will be set to a new value.

Now, to increment the variable click on the arrow between Set variable and Compose. Click on Add an action.

Select Increment Variable.

Select the variable Name and add Value. This will only work for variables that are of numeric data type.

Test and Run Flow. Now click on Compose. Now the variable value will be incremented by 4. Similarly, you can do it for Decrement operation.

 

To use the Append operation create a new variable of type String

Select Append to a string variable.

Add Compose from actions. Add My Name variable from Add dynamic content. Click on Save.

Test and Run Flow. Click on Compose. The new string is appended to the previous string variable.

 

Appending To An Array

Initialize the variable with data type as Array. Enter values in Array format enclosed in square brackets and separated by commas. Go to New step.

Select Append to array variable from actions.

Select the variable name and add value. Click on the New step.

Select compose from actions. Select the variable name from dynamic content and Save.

Test and run flow. You can see the output where the new string is appended to our array