How to Convert a String to an Integer in Power Automate?

Are you trying to convert a string value to an Integer value in Power Automate? This Power Automate tutorial will help to convert a string to an integer in Power Automate.

Sometimes, when the user enters a number value in a text data type, it comes as a text value in a Power Automate flow, and it causes further steps presented in the flow.

For example, we need two integer values to perform an addition, so the user enters the first input value as 10 in the String data type and the second as 15 in the Integer data type. While performing the addition, the flow fails.

So, in this case, we need to convert the first input value from the String data type to the Integer data type and perform the addition operation. So, the flow will run without any errors and display the output value of the addition operation as expected.

Now we will create a flow to convert String to Integer using Power Automate Flow,

How to convert String to Integer in Power Automate Flow

Let us see how to convert string to integer in Power Automate Flow,

Step-1:

Create an instant cloud flow, Expand the manual trigger action, and add two input values. The first input value is the text data type, and the second input value with the number data type.

power automate convert string to integer

Step-2:

To convert the first input value from the String data type to an integer data type we are going to use the int() function.

See also  How to create a filter in Power bi

Add a compose data operation from the action triggers and pass the below expression.

int(triggerBody()['text'])

Where,

  • int – function name
  • triggerBody()[‘text’] – first input value
How to convert string to integer in Power Automate flow

Step-3:

We will perform an addition once the String input value is converted to the integer value. For that, select the compose data operation and pass the below expression, which performs the addition of two integer values.

add(outputs('Convert_String_Value_to_Int_Value'),triggerBody()['number'])

Where,

  • add – function name
  • Convert_String_Value_to_Int_Value – first input value
  • triggerBody()[‘number’] – second input value
How to convert string to integer in Power Automate

Step-4:

Save and Run the flow; enter the two input values and click on the Run flow option.

Convert text to number in power automate flow

Once the flow runs successfully, we can see the flow performs an addition and displays the output value as expected.

Convert a String to an Integer in Power Automate

This is how to convert a string to an integer in Power Automate Flow.

Conclusion

So, I hope now you get an idea of why we need to convert the String value to an integer value in Power Automate flow.

By using an int() function, we can easily convert the string values to an integer value, and this supports all the values that are strings when you expect them to be a number in Power Automate.

You may also like:

>