How to Convert a String to Integer in Power Automate

Do you need to convert a string to an integer number in your flow?

Converting a string to an integer is a common task that is often necessary when working with data from various sources.

What looks like a number might actually come into Power Auatome as a string. This might cause errors in your flow in later steps if you are trying to manipulate them as numbers.

You will need to convert these text strings to numbers before you can perform any calculations with them.

This post will show you how to change a text value to a number in Power Automate.

Convert String to Integer

The Microsoft Forms connector is one that commonly causes issues with mixing text and numbers.

In Microsoft Forms it is possible to restrict answers to a number value.

But when retrieving this answer in Power Automate with the Get response details action, it will be a text value.

When you try and use this value in any operation that requires a number, the flow will end in error.

You will first need to convert this value to a number before you can use it as a number.

Int(outputs('Compose'))

This is quite an easy fix! You can use the Int() function to convert a string to an integer value.

The above formula will convert the Number dynamic content in the Compose action, which is from the Get response details action, to an integer.

You will then be able to use the results of this formula as a number.

You can also convert a text to a decimal number using the Float() function.

Conclusions

Values that are strings when you expect them to be a number are a common problem in Power Automate, especially when using the Forms connector.

Once you identify the issue, it’s an easy fix to first convert the text value to an integer with the Int function.

Have you come across this data type issue before? Let me know in the comments below!

About the Author

John MacDougall

John MacDougall

John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

Subscribe

Subscribe for awesome tech videos 😃

Related Articles

Comments

0 Comments

Submit a Comment

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

Get the Latest Tech Tips

Write For Us

Are you a tech enthusiast with a talent for writing great content? Come write for us!

Follow Us

Follow us on social media to stay up to date with the latest in tech!