How to Initialize Integer Variable in Power Automate?

This Power Automate tutorial explains how to initialize integer variable in Power Automate with an example.

Initialize Integer Variable in Power Automate

  • One of the variable datatypes in Power Automate flow is an Integer data type. When we initialize a variable with an integer variable type, it accepts the Whole number value that can be positive, negative, or zero.
  • When we initialize a variable with integer type, it accepts only the Single Parameter in the value section. It will not accept multiple values.

In the following example, we will see how to initialize a variable Integer in Power Automate flow.

Let us see how we can initialize a variable Integer in the Power Automate flow.

Example-1:

In this example, we will use two integer values as input values to calculate the previous month and current month sales values, and add then we will initialize a variable to add the previous month’s and current month’s sales values.

Create an instant cloud flow, select the trigger as manually trigger a flow, and click on the create option.

Power Automate Initialize Variable Integer
  • Expand the Manually trigger flow, and choose the type of user input by selecting +Add an input and select the Number variable type.
Power Automate initialize variable type integer
  • Now add the +new step, select the initialized variable to enter the variable name, choose the variable type as Integer, and in the value section, pass the dynamic value.
  • In this example, I have added a Current Month’s sales value. In the same way, initialize another variable to get the Previous Month’s Salesvalue as below:
Power Automate initialize variable type integer example

Now, we will add the compose action, to add the two sale values using the add function from the initialized variable to get output.

add(variables('VarInt1'),variables('VarInt2'))

Where,

  • add -> Function name
  • VarInt1,VarInt2 -> Initialized Variables names
Example of Power Automate initialize variable type integer
  • Save and Test the Power Automate flow and then Run the flow automatically.
  • In the screenshot below, in the compose action, you can see it displays the addition of the current month sales value and the previous month’s sales value, as highlighted below:
Power Automate flow initialize variable type integer

This is how to initialize the variable Integer in Power Automate flow.

Example:2

In the same way, in this example, we will subtract the initialized variable’s values with the type of Integer in Power Automate flow.

  • Select the created Power Automate instant cloud flow, expand the trigger action, select Add an input ->, and then choose the input type as a Number.
  • Enter the Name and pass the numeric value in the value section as highlighted below:
Initialize Variable Integer type in Power Automate example
  • Now add the +new step and select the initialize variable, then enter the variable name and choose the variable type as Integer. In the value section, pass the dynamic value for the Generator age.
  • Similarly, add the dynamic value for the Generator Warranty Period with the variable type as an Integer.
Example of Initialize Variable Integer type in Power Automate
  • Select the compose action to calculate the remaining generator warranty period in years, enter the below expression click update or ok option.
sub(variables('Generator Warranty Period'),variables('Generator Age'))

Where,

  • sub -> Function name
  • Generator Warranty Period,Generator Age -> Initialized Variables names
Example of Initialize Variable Integer in Power Automate
  • In the below screenshot, we can see that the compose action displays the remaining generator warranty period as below:
Initialize Variable type Integer in Power Automate

This is another example of initializing an integer variable in Power Automate flow.

In this Power Automate Tutorial, I have explained how to initialize an integer variable in Power Automate.

You may like the following Power Automate tutorials: