Variables are one of the most valuable actions in Power Automate, and today, we’ll look at how the “increment variable” action works.

The “increment variable” action will get an “Integer” or “Float” variable and increment it by the value that you provide it. It’s pretty simple but super powerful since having an action that we can do this safely can save us from some issues.

So the concept is simple. You have a variable with a value; after the “increment variable” the variable will contain a value that is the sum between it and the value provided.

Where to find it?

You can find it in the “Build-in” action.

You may need to extend it and search for “Variables.”

Select “variables.”

Select the “increment variable” action.

Here’s what it looks like.

Pro Tip:
Power Automate tends to save the most common actions in the main screen, so check there before going through the full hierarchy. Also, you can use the search to find it quickly.

Now that we know how to find it let’s understand how to use it.

Usage

The first thing that is important to understand is that the “increment variable” action needs a variable to increment. It may look obvious, but sometimes it would be helpful to define a variable and increment it “on the spot,” but it’s not possible.

If you don’t have a variable, here’s what it would look like.

Not very useful, right?

Another thing to consider is that the “Increment Variable” action will only work if the variable is an “Integer” or a “Float.” Even if you have a string variable that contains a number, it won’t work. We can easily see it here:

Let’s see it in action now that we know what we can use. First, let’s see how to increment it to a numeric value:

Notice that we’re not even initializing the variable with a value. This is a nice touch from Microsoft, where if the variable doesn’t contain an initial value, then Power Automate considers it zero.

How about if we want to increment an “Integer” variable with a floating point number? Like this:

Power Automate will do the “right thing” and block us from doing it since we cannot have a valid result.

How about the opposite? If we have a “Float” variable and want to add a numeric value?

No problem since the value makes sense in the end:

Finally, let’s try the floating point value on a “Float” variable.

No problem. The value is possible to add, so Power Automate does it without an issue.

Non-intuitive behaviors

Usually, in Power Automate, we typically use the actions’ outputs where we get the data. For example, if we have a “compose” action, we fetch the result of the expression on the “compose” action output. But in the case of the “increment variable” action, we are not doing that. We are changing the content of the variable that exists elsewhere, meaning that if we want the incremented value, we need to access the variable.

It makes sense if you think about it, but I wanted to highlight this because it’s something that escapes a bit from the “norm” on how Power Automate works.

Limitations

I understand there’s no severe limitation to the “increment variable” action, but if you’re aware of one, I would like to know about it. Please email me, and I’ll include it here.

Recommendations

Here are some things to keep in mind.

Name it correctly

The name is super important in this case since we can have a lot of variables per Flow. Always build the name so that other people can understand what you are using without the need to open the action and check the details.

Always add a comment.

Adding a comment will also help avoid mistakes. Indicate the variable’s usage and why you’re adding the value. Also include the meaning of the value itself, for example, “increments the value by 1 to count the number of items in the array”. It’s essential to enable faster debugging when something goes wrong.

Always deal with errors.

Have your Flow fail graciously and notify someone that something failed. It’s horrible to have failing Flows in Power Automate since they may go unlooked-for a while or generate even worse errors. I have a template that you can use to help you make your Flow resistant to issues. You can check all details here.

Am I missing something? Leave a comment or interact on Twitter. Let’s work together to make this reference as complete as we can

Back to the Power Automate Action Reference.

Photo by Tim Mossholder on Unsplash

 

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

Leave a Reply

Your email address will not be published. Required fields are marked *