How to Convert String to Integer in Power Automate?

Are you aware of converting a string to an integer using Power Automate? If not, then read this complete tutorial where I have explained how to convert string to integer in Power Automate.

I have also explained an example based on how to convert a string to an integer with Power Automate.

Power Automate Convert String to Integer

In a Microsoft Power Automate flow, a user needs to convert a string to an integer before performing any calculations with the data.

This is because a number that looks like an integer might be a string in Power Automate. So, we need to convert the string to an integer by using the Int function.

The Int function in Power Automate can be used to convert a string value to an integer value. Int function is also limited because it can only hold a certain number of digits where the Power Automate flow fails after 20 digits.

Syntax: int(value:string) provide value as int(outputs('Compose'))
  • The below image shows the conversion of string to integer:
Power Automate Convert string to integer

Follow the below instructions to convert a string to an integer in Power Automate:

To work with this, I have taken a SharePoint list named ‘Course Enrollment Form ‘ with different datatypes as shown below:

Column NameDatatype
Course to EnrollTitle column
Full NameA Single line of text
Email AddressA Single line of text
Date of EnrollingDate and Time
Course FeeNumber column
Period in YearsA Single line of text

Scenario:

To multiply course costs by a period in years, I change the text in the period in years field to an integer value rather than a string.

The overall cost of a course will now be calculated by sending an email to the user with the total cost of a course based on the period in years.

How to Convert String to Number Using Power Automate
  • Create an Automated cloud flow with a trigger ‘ When an item is created or modified ‘ and set below details:
    • Site address: Select a specific SharePoint site from the drop-down.
    • List Name: Select a SharePoint list from a drop-down.
Convert String to Number in Power Automate
  • Then, add a Get items action and provide the below details:
    • Site address: Select a SharePoint site from the drop-down.
    • List Name: Select a SharePoint list from a drop-down.
Convert String to Number in a Power Automate
  • Next, add an Initialize variable and set the below details:
    • Name: Provide a name for an initialized variable.
    • Type: Select datatype as ‘String’ from the drop-down.
    • Value: Select values that need to be converted as an integer from dynamic content.
  • Here, I was taking a column that contained string values in it i.e. Period in years.
How to convert a string to an integer in Power Automate
  • Now, add a Compose data operation and give the expression as placed in the code below:
int(variables('Period in Years'))
Convert string to number using Power Automate
  • Now, I wanted to multiply this integer with another number column on Power Automate. For this, I will add another compose action and insert the below expression:
mul(outputs('Compose'),triggerOutputs()?['body/CourseFee'])
Power Automate convert text to number by int function
  • Then, add a Send an email(V2) action and provide the below details:
    • To: Select an email address from dynamic content.
    • Subject: Enter a subject for an email.
    • Body: Provide detailed information regarding email in the format as shown below image:
Hello @{triggerOutputs()?['body/FullName']},
Hope you are doing well!
You have been enrolled for the course '@{triggerOutputs()?['body/Title']}' on @{triggerOutputs()?['body/DateofEnrolling']} for the period of @{triggerOutputs()?['body/PeriodinYears']} years and course delivery will be in the mode of @{triggerOutputs()?['body/CourseDelivery/Value']}.
Total Cost -@{outputs('Compose_2')}

Thanks and Regards
Management Team
Convert Text or string to Number or Integer using Power Automate
  • Once the flow is ready, click on Save and Test.
Convert string in integer all the time with Power Automate
  • Then, add an item to the SharePoint list; if there are no errors, the flow runs successfully, as shown below image:
Converting text to integer in Power Automate
  • The image that is placed below will represent an email notification received by the user:
Converting text to integer in Power Automate flow

This is how to use the int function in converting string to integer in a Power Automate flow.

Conclusion

Through this Power Automate tutorial, I hope you got an idea of how to convert string values to integer values by using the int() function in a Power Automate flow.

You may also like the following tutorials: