How to Convert String to Integer in Power Automate?

Recently, while working on a Power Automate Flow to generate a PDF from SharePoint list items, I encountered a challenge: some numerical values stored in my SharePoint list were in text format instead of numbers. This became a problem when I needed to perform calculations, as Power Automate treats string values differently from integers.

If you have ever faced a similar issue, don’t worry! Power Automate provides an easy way to convert a string to an integer using the int() function. In this tutorial, I will tell you how to convert a string to an integer in Power Automate.

INT Function in Power Automate

Power Automate int() function converts a number or numeric string into an integer (a whole number). It removes any decimal part and returns only the entire number.

Syntax:

int('<value>')
INT Function in Power Automate
  • Input: You can give it a number or a string ( “12”).
  • Output: It will give you a proper Integer value (12).

Convert String to Integer in Power Automate

Suppose you have a SharePoint list called Sales Orders with a column named Order ID (Single line of text). Each Order ID follows the format “SO-1001”, “SO-1002”, etc.

Convert String to Integer in Power Automate

Now, you need to extract the numeric part of the Order ID, convert it into an integer, add 10, and store that value in the Updated Order Number (number) column.

To do this, follow the below steps:

1. Create an Automated Cloud Flow using the SharePoint connector’s When an item is created trigger. Select the SharePoint site where your Sales Orders list is present, and choose the Sales Orders list.

power automate convert string to int

2. Add Compose action to extract the numeric part from Order ID. To do this, use the following:

replace(triggerBody()?['OrderID'],'SO-', '')
  • triggerBody()?[‘OrderID’]: Gets the value from the Order ID column (e.g., “SO-1001”).
  • replace(text, oldValue, newValue): Replaces “SO-” with “” (empty string).
How to Convert a String to Integer in Power Automate

3. Add a Compose action to convert the string to an integer:

int(outputs('Compose'))
Convert String to Number using Power Automate

4. Then, add a Compose action to add 10 to the order number.

add(outputs('Compose_1'),10)
How to Convert a String to Integer in Power Automates

5. Add an Update item action to update the Compose action value in the ‘Updated Order Number’ column and provide the following parameters:

  • Site Address: Select a specific SharePoint site from drop-down.
  • List Name: Choose a particular list.
  • Id: Select Id from dynamic content under When an item is created.
  • Updated Order Number: Provide the output from dynamic content compose 2.
Convert String to Integer using Power Automate

Save the flow and run it manually. Then, go to the SharePoint list and add a new item.

Power Automate Tips Convert int to string

After the flow runs successfully, refresh the SharePoint list. The value will be updated in the ‘Updated Order Number‘ column.

How to convert a string to a number Using MS Flow

Conclusion

In this tutorial, we tackled the issue of converting a string to an integer in Power Automate using the int() function. We worked with a SharePoint list where the Order ID column stored values as text (“SO-1001”). We used the replace() function to extract the numeric part, then converted it to an integer using int(), added 10, and updated the Updated Order Number column.

You may like the following tutorials:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…