Table of content

Variables In Power Automate

In this article, we will learn about variables, data types, creating variables, and how to perform operations and actions on them.

In previous chapters, we were sending one email for every product. 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

Power Automate provides data types like Boolean, Integer, Float, String, Object, and Array.

  • 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

  • Before we use variables we need to initialize them to define storage and memory to variables.
  • Let's go to our Microsoft Power Automate.
  • Click on Create from the left-hand side panel. Select Instant cloud flow.
    create-instant-flow
  • Give a name to the flow and select Manually trigger a flow. Click on Create.
    new-variable-trigger
  • Click on the New step to add Variables.
    manually-trigger-flow-var
  • We need to create a variable. Select Initialize variable from actions.
    initialise-var
  • Enter Name for your variable. Select the data type of your variable.
  • Assign the Value to the variable and click on the New step.
    created-var
  • Select Compose (Data Operation) from actions. With 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.
    compose-var
  • Add Input as My Age variable from Add dynamic content. Click Save.
    myage-var
  • Now, Test and Run Flow by Manually triggering it.
    test-flow-variable
  • After running the flow. We can the Output in Compose.
    output-var

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.
    add-action-var
  • Select Set variable from actions.
    set-variable-var
  • Select the previous variable My Age and add Value to it.
    set-variable-age-var
  • Test and Run Flow. Now click on Compose. Now the variable value will be set to a new value.
    output-set-var
  • Now, to increment the variable click on the arrow between Set variable and Compose. Click on Add an action.
    increment-var-add-action
  • Select Increment variable.
    increment-var
  • Select the variable Name and add Value. This will only work for variables that are of numeric data type.
    values-incrment-var
  • 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.
    increment-var-output
  • To use the Append operation create a new variable of type String.
    string-var
  • Select Append to a string variable.
    append-var
  • Select the variable Name and add Value.
    append-staring-var
  • Add Compose from actions. Add My Name variable from Add dynamic content. Click on Save.
    append-compose-var
  • Test and Run Flow. Click on Compose. The new string is appended to the previous string variable.
    append-output-var

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.
    array-power-automate-var
  • Select Append to array variable from actions.
    append-array-var
  • Select the variable name and add value. Click on the New step.
    array-addition-var
  • Select Compose from actions. Select the variable name from dynamic content and Save.
    array-compose-var
  • Test and Run Flow. You can see the output where the new string is appended to our array.
    array-compose-output-var
0 results
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions