Skip to content

Power Automate Variables: Types, Actions, and How to Use Them

How Power Automate variables work: the six data types, the Initialize, Set, Increment and Append actions, a loop-counter example, and variable vs Compose.

Citizen Development Academy Updated 5 min read
Power Automate Variables: Types, Actions, and How to Use Them
In this article · 12 sections

A variable in Power Automate is a named, typed value you can change as a flow runs. That is what sets it apart from a Compose action, which holds one fixed value: a variable can be a running total you add to in a loop, a flag you flip when a condition is met, or a list you append items to. This guide covers the six variable types, the actions that create and update them, a worked loop-counter example, and the rules that decide when a variable is the right tool.

Updated June 2026 against Microsoft’s store and manage values in variables guide.

What a variable is

A variable holds data of a chosen type while the flow runs. Two properties matter:

  • Variables are global to the flow. Once initialized, a variable is available to every later step, and its value persists across loop iterations. That is exactly what lets it accumulate a result.
  • You reference a variable by name, with the variables() function, for example variables('Count'). This is different from a Compose action, which you reference by action name with outputs().

The six variable types

When you initialize a variable, you pick one type, and it holds that type for the life of the flow.

TypeHoldsExample use
StringTextA name, a URL, a built-up message
IntegerWhole numbersA loop counter, an item tally
FloatDecimal numbersAn average, a percentage, a measurement
BooleanTrue or falseA flag set when a condition is met
ArrayA list of values or objectsItems from a SharePoint list or an API
ObjectA structured value with propertiesA parsed JSON record

The variable actions

Power Automate gives you a small set of actions to create and change variables.

ActionWhat it doesNotes
Initialize variableCreates the variable, sets its name, type, and starting valueOne variable per action; must sit at the flow’s top level, not inside a loop or condition
Set variableReplaces the value with a new oneThe variable must already be initialized
Increment variableAdds a constant (default 1)Integer and float variables only
Decrement variableSubtracts a constantInteger and float variables only
Append to string variableAdds text to the end of a String variableGrows the value without replacing it
Append to array variableAdds an item to the end of an Array variableGrows the value without replacing it

Two rules catch people out. Initialize variable can only run at the top level of the flow, not inside a Scope, Condition, or loop. And Increment and Decrement work only on variables initialized as Integer or Float: a value that arrives as a string must be Set into an Integer or Float variable first (convert it with int() or float(), see the functions guide). You cannot increment a String variable.

How to initialize a variable

  1. In your flow, add an action and search for Initialize variable.
  2. Set a clear Name (Count, CustomerEmail), choose the Type, and set an initial Value. The value is optional, but setting it means you always know the starting point.
  3. Add it near the top of the flow. Each variable needs its own Initialize variable action.

From there, use Set variable to replace the value, or Increment, Decrement, and the Append actions to change it in place.

A worked example: count email attachments

A loop counter is the most common use of a variable, because Compose cannot accumulate across iterations and a variable can.

  1. Start the flow with a trigger such as When a new email arrives (V3), set to fire only on mail with attachments.
  2. Add Initialize variable: name Count, type Integer, value 0.
  3. Add an Apply to each loop over the email’s Attachments array.
  4. Inside the loop, add Increment variable on Count (default value 1).
  5. After the loop, send yourself the result, referencing variables('Count').

Each pass through the loop adds one to Count, and because the variable is global and persists across iterations, the total survives to the step after the loop.

One caution: if you switch an Apply to each loop to run in parallel for speed, a shared counter variable can produce unpredictable results, because parallel branches update the same global variable with no ordering guarantee. The same shared, mutable state that lets the counter accumulate is what makes parallel writes race. Keep loops that update a variable running sequentially when the count has to be exact.

Variable or Compose: which to use

Both hold data; the difference is whether it changes.

AspectVariableCompose
Use whenThe value changes (counter, flag, list)The value is computed once and reused
Needs initializationYes, with Initialize variableNo
Can be updated laterYes, with Set, Increment, or AppendNo, fixed when it runs
Reference withthe variables() functionthe outputs() function
Overwrite riskCan be overwritten later in the flowCannot be changed after it runs

If you are writing the same expression in several places, that is a Compose action; if you are updating a value in a loop, that is a variable.

Best practices

  • Name variables for their purpose. Count and CustomerEmail read better six steps down than var1.
  • Keep each variable’s updates near where it is read. Initialize actions all sit at the top level anyway, so group the Set, Increment, and Append steps close to where the value is used, to keep its lifecycle easy to trace.
  • Match the type to the data. Use Integer or Float for anything you will Increment, and Array for anything you will loop over or append to. For an exact running total, or money that must reconcile to the cent, use Integer (or integer cents): Float is binary floating point and accumulates rounding error over many increments, so reserve it for values where small drift is acceptable.
  • Watch parallel loops. A variable updated inside a parallel Apply to each can race; run the loop sequentially when the result must be exact.
  • Do not overuse them. If a value never changes, a Compose action or a single expression is simpler than initializing a variable.

Frequently asked questions

How do I reference a variable in Power Automate?

Use the variables() function with the variable’s name, for example variables('Count'), or pick it from the dynamic content list. Variables are referenced by name, unlike a Compose action, which you reference with outputs('<action name>').

Why can’t I add Initialize variable inside my loop?

Initialize variable can only run at the flow’s top level, not inside a loop, condition, or Scope. Initialize the variable above the loop, then use Set, Increment, or Append inside it.

What types of variables can Power Automate create?

Six: string, integer, float, boolean, array, and object. You choose the type when you initialize the variable, and it holds that type for the rest of the flow.

What is the difference between a variable and a Compose action?

A variable is initialized once and can be updated throughout the flow (Set, Increment, Append), and you reference it with variables(). A Compose action holds a single value that is fixed when it runs and is referenced with outputs(). Use a variable for values that change and Compose for values that do not.

To go from single actions to designing complete, maintainable flows with loops, conditions, and variables, our Power Automate training walks through it end to end.

Stay in the loop

Get new posts delivered to your inbox. No spam, unsubscribe anytime.

Related articles