Power Automate Increment Variable

Are you looking at how to increment variable in Power Automate? In this tutorial, I will show you everything about the Power Automate increment variable with examples. I will show you how to increment variable by 1 in Power Automate as well as Power Automate increment variable in apply to each.

Power Automate increment variable

You can use the increment variable Power Automate flow action to increase the value of an existing variable. Power Automate increment variable flow action only works with float and integer type variables.

Let us see with an example how to use increment variable in Power Automate. In particular, I will show you an example of Power Automate: add a number to a variable.

Here, I will create a flow that will trigger manually in Power Automate. So I will create an instant cloud flow. Follow the below steps:

1. Open the Power Automate home page, and log in with your Microsoft 365 credentials. Then click on + Create -> Instant cloud flow like below:

power automate increment variable

2. Next, enter the name of the flow and choose the trigger as “Manually trigger a flow“. This will create a button flow for mobile.

increment variable power automate

The flow will be created, and you can see below screenshot from where we can add any flow action.

Power automate increment variable

4. Now, before adding the “power automate increment variable” flow action, we will create a variable of type integer. So that, we can see, how to use increment variable in Power Automate.

To create and initialize a variable in Power Automate, click on the +New step -> search for Initialize variable -> Add it. And set the Name, type, and value such as:

  • Name- varInteger
  • Type- Integer
  • Value- 60
increment variable in Power Automate

5. Now, I will show you how to add the “increment variable” flow action to increment the variable we created in the above step. For this, click on +New step > search Increment variable > add it.

Here, we will call the variable name that we have initialized and set an increment value.

  • Name- varInteger
  • Value- 12

We can see it will increase the variable’s value from 60 to 72.

increment variable in power automate
increment variable in power automate

6. Now, I will add a compose action to display the increment value. Click on + New step, then add a compose action like below. In the compose action, assign the variable like below.

power automate increment variable

7. Now, the flow to increment variable in Power Automate is ready, and we can test it. Once you Save and Run the flow, you can see the flow trigger successfully, and in the compose action, you can see the value of the variable.

power automate counter variable

This is how to use the “Power Automate increment variable” flow action to increment a variable in Power Automate.

Power Automate increment variable by 1

Here, I will show you an example of “Power Automate increment variable by 1“. Exactly, I will show you how to increment variable by 1 in Power Automate.

1. You create an instant cloud flow in Power Automate by following the above steps. But in this case, I want the flow to ask the user to enter the value. So, to implement this, add a number input inside the trigger(i.e., Manually trigger the flow).

Click on +add an input > select Number like in the below screenshot.

Power Automate increment variable by 1

2. In the next step, you need to create a variable of type integer and the assign the value from the Number input.

To declare a variable, Click on +Next step > Initialize variable (search for the action) > Add it. Set the properties such as:

  • Name- VarNumber
  • Type- Integer
  • Value- @{triggerBody()[‘number’]}
power automate increase variable by 1

3. Next to increment variable by 1 in Power Automate, I need to add the Power Automate increase variable flow action to it.

Click on + Next step > Increment variable > Add it, where we will set the parameters such as:

  • Name- VarNumber
  • Value- 1
How to increment variable by 1 in Power Automate

4. After you configure this, the variable will be incremented by 1 when the Power Automate flow runs. To check this, add a compose action into the flow in Power Automate.

power automate add 1 to variable

5. The flow to add 1 to variable in Power Automate is ready and you can test it. When you will run the flow, it will ask to insert a number (any dynamic input). Let’s insert a number as 23 > click on Run flow.

power automate increment variable by 1

6. You can in the screenshot below where, it will increment variable by 1 in Power Automate flow, We can see the value incremented by 1 i.e., 24.

power automate increment variable by 1

This is how to increment a variable by 1 in Power Automate.

Power Automate increment variable in apply to each

Now, let us see another example of “Power Automate increment variable in apply to each“. In this case, when you will run the flow, it will increment a variable in apply to each in Power Automate.

For example, we have an array having null values such as [1,1,null,2,null,3]. We will calculate this array in Power Automate by looping and incrementing the total variable by another field value. Let’s start the calculation, and the following steps are:

Step-1:

First, we will initialize an array variable using the above value.

  • Name- VarArray
  • Type- Array
  • Value- [1, 1, null, 2, null, 3]
Power Automate increment variable in apply to each

Step-2:

Again, we will add another action to initialize the integer variable. Set the properties such as:

  • Name- VarTotal
  • Type- Integer
  • Value- 0
increment variable in apply to each In Power Automate, power automate add 1 to variable

Step-3:

Next, we will add an action for looping the array value. For this, Click on +Next step > Apply to each. In this action, we will use the VarTotal as output.

  • Select an output from previous steps– VarTotal

Inside that loop, we will use another action to calculate the increment of the array variable, i.e., the Increment variable flow action.

  • Name- VarTotal
  • Value- @{items(‘Apply_to_each’)} (search for current item in dynamic content)
power automate increment variable in apply to each

Now, our flow is ready to run. As we know, null means 0. But the increment variable action indicates the value of 1 where the increment by parameter is not given i.e., the null value.

Note:

According to Array, it will calculate as:

1=1
1+1=2
2+null(1)=3
3+2=5
5+null(1)=6
6+3=9
How to increment a variable in Power Automate using Apply to each

But we can use the null value as 0 in the increment variable action by using this expression instead of using current item.

coalesce(items('Apply_to_each'),0)

Note:

The coalesce() in Power Automate returned the first non-null object in the arguments passed in.

increment variable in apply to each in power automate

The final result comes as:

1=1
1+1=2
2+null(0)=2
2+2=4
4+null(0)=4
4+3=7
increment variable in apply to each in power automate

This is how to increment a variable in apply to each loop using Power Automate flow.

Conclusion

I hope now you got an idea on how to use the Power Automate increment variable flow action. Also, I have explained with an example, how to increment a variable by 1 in Power Automate. In the last example, I have explained you “Power Automate increment variable in apply to each“. This is how to use increment variable in Power Automate.

You may also like:

>