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!
Hi! This was helpful to me but I have a question I’m hoping you can help with. I have failed repeatedly at using Int() and float() to convert string numbers to integers. I have an array that includes numbers in string format. I need to convert them into integers but I am getting the error “The template language function ‘int’ was invoked with a parameter that is not valid. The value cannot be converted to the target type” every time. Same with Float(). My data includes negative numbers but no decimals. I need the fields Points_Total and Points_Effort to be integers so I can use them in later functions.
e.g.
“Project Manager”: null,
“Points_Total”: “250”,
“Points_Effort”: “-30”,
“Priority”: “Not Critical”,
Thank you for any advice you can provide.
James
Are you trying to use something like
int(array)
? I don’t think you can pass an array, only a scalar value.