How to Initialize Integer Variable in Power Automate

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

Also, Read: How to Initialize Object Variable in Power Automate

Initialize Integer Variable in Power Automate

  • In Power Automate flow One of the variable datatypes 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, and select the trigger as manually trigger a flow and click on the create option.

Power Automate Initialize Variable Integer
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
Power Automate initialize variable type integer
  • Now add the +new step and select the initialized variable to enter the variable name and choose the variable type as Integer and in the value section pass the dynamic value.
  • Here 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
Power Automate initialize variable type integer example

Now we will add the compose action, to add the two sale values using 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
Example of Power Automate initialize variable type integer
  • Save and Test the Power Automate flow and then Run the flow automatically.
  • In the below screenshot, in the compose action you can see it displays the addition of current month sales value and the previous month sales value as highlighted below:
Power Automate flow initialize variable type integer
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 how to subtract the values of the initialized variable with the type of Integer in Power Automate flow.

  • Select the created Power Automate instant cloud flow, expand the trigger action and 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
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 and in the value section pass the dynamic value for Generator age.
  • In the same manner, add the dynamic value for Generator Warranty Period with the variable type as Integer.
Example of Initialize Variable Integer type in Power Automate
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
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
Initialize Variable type Integer in Power Automate flow

This is another example to initialize an integer variable in Power Automate flow.

In this Power Automate Tutorial, we have discussed what is Initialize Variable Integer and how to initialize integer variable in Power Automate with a few examples.

You may like the following Power Automate tutorials: