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.
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 examplevariables('Count'). This is different from a Compose action, which you reference by action name withoutputs().
The six variable types
When you initialize a variable, you pick one type, and it holds that type for the life of the flow.
| Type | Holds | Example use |
|---|---|---|
| String | Text | A name, a URL, a built-up message |
| Integer | Whole numbers | A loop counter, an item tally |
| Float | Decimal numbers | An average, a percentage, a measurement |
| Boolean | True or false | A flag set when a condition is met |
| Array | A list of values or objects | Items from a SharePoint list or an API |
| Object | A structured value with properties | A parsed JSON record |
The variable actions
Power Automate gives you a small set of actions to create and change variables.
| Action | What it does | Notes |
|---|---|---|
| Initialize variable | Creates the variable, sets its name, type, and starting value | One variable per action; must sit at the flow’s top level, not inside a loop or condition |
| Set variable | Replaces the value with a new one | The variable must already be initialized |
| Increment variable | Adds a constant (default 1) | Integer and float variables only |
| Decrement variable | Subtracts a constant | Integer and float variables only |
| Append to string variable | Adds text to the end of a String variable | Grows the value without replacing it |
| Append to array variable | Adds an item to the end of an Array variable | Grows 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
- In your flow, add an action and search for Initialize variable.
- 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. - 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.
- Start the flow with a trigger such as When a new email arrives (V3), set to fire only on mail with attachments.
- Add Initialize variable: name
Count, type Integer, value0. - Add an Apply to each loop over the email’s Attachments array.
- Inside the loop, add Increment variable on
Count(default value 1). - 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.
| Aspect | Variable | Compose |
|---|---|---|
| Use when | The value changes (counter, flag, list) | The value is computed once and reused |
| Needs initialization | Yes, with Initialize variable | No |
| Can be updated later | Yes, with Set, Increment, or Append | No, fixed when it runs |
| Reference with | the variables() function | the outputs() function |
| Overwrite risk | Can be overwritten later in the flow | Cannot 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.
CountandCustomerEmailread better six steps down thanvar1. - 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
Free Power Automate Training: Where to Actually Start in 2026
Genuinely free Power Automate training: official Microsoft Learn paths, free hands-on practice, free guides, plus an honest note on where free stops.
Power Automate for Outlook: Triggers, Actions, and Patterns (2026)
Power Automate for Outlook: the email and calendar triggers and actions that matter, copy-ready flow patterns, and the limits that quietly break inbox flows.
Power Automate for Teams: Triggers, Actions, and Patterns (2026)
Power Automate for Microsoft Teams: posting messages and approval cards, the triggers that start a flow, copy-ready patterns, and the limits to plan around.