How to Extract Number from String in Power Automate?

Do you need to extract only numbers from the string using Power Automate flow? This tutorial is for you; here, I will show you how to extract numbers from a string in Power Automate.

Scenario:

Recently, while working on the Project, I needed to extract and display only the numbers from the String. For example, My input string looks like the below:

A1B2C3D4

After extracting number values from String using flow, I have to display the output value as below:

1234

Here, I will explain static and dynamic ways of extracting numbers from string values using Power Automate flow.

Now, we will create a flow to extract numbers from strings using flow.

Extract Number from String using Power Automate

Let us see how to extract numbers from strings in the Power Automate flow

Example-1: (Static way)

In this example, I will show you how to extract numbers from strings in Power Automate.

Step-1:

Create an instant cloud flow with a manual trigger, add a new step, select the initialize variable action, and Provide the below parameters:

  • Name – Enter the variable name
  • Type – Choose the variable type as String
  • Value – enter the below value
1PowerApps2PowerAutomate3PowerBI4PowerFX
power automate extract number from string

Step-2:

Add a new step and choose the select data operation; in the from section, pass the below expression, which splits the value and returns the array

chunk(variables('StringValue'),1)

In the Map section, switch the map to the text mode and use the below expression, which checks if the value is an integer and then returns the exact value; else, return the null value by using the if function and isInt() expression.

if(isInt(item()),item(),null)
How to Extract Number from String using Power Automate

Step-3:

Add a new step, choose the compose data operation, and use the below expression, which displays only the numbers from the input string value.

join(body('Select'),'')
How to Extract Number from String using Power Automate flow

Step-4:

Save and run the flow by clicking on the run flow option. Here, in the Output of the compose data operation, we can see the expected result, which extracts only numbers from the string values.

Extract Number from String using Power Automate flow

This is how to extract numbers from strings in the Power Automate flow.

Example – 2:( dynamic way)

In this example, I will show you how to extract only numbers from a SharePoint list text column using flow.

Here, I am going to use the below Products SharePoint list, which consists of

  • Product Name – default title column
  • Product ID – Single line of text
Extract Number from String using Power Automate

Step-1:

Create an instant cloud flow with a manual trigger, select Get items action from action triggers, and configure the required parameters.

  • Site Address â€“ select the SharePoint site address from the dropdown
  • List Name â€“ choose the SharePoint list. Here, I have selected my Product list
Extract Number from String in Power Automate

Step-2:

Add a new step, choose an Apply to each control, and pass the value from the dynamic content

Extract Number from String in Power Automate flow

Add a new step and choose the select data operation; in the from section, pass the below expression, which splits the value and returns the array

 chunk(items('Apply_to_each')?['ProductID'],1)

In the Map section, switch the map to the text mode and use the below expression:

if(isInt(item()),item(),null)
How to extract ONLY numbers from string in Power Automate

Now, we will update the extracted number in the Extracted number from string field

For that, Add a new step, choose the Update item action from action triggers, and provide the below parameters:

  • Site Address â€“ select the SharePoint site address from the dropdown
  • List Name â€“ choose the SharePoint list. Here, I have selected my product list
  • ID â€“ choose the ID from dynamic content values

In the ExtractedNumberfromString field, and use the below expression:

join(body('Select'),'')
How to extract ONLY numbers from string in Power Automate flow

Step-3:

Save and run the flow once the flow runs successfully like below:

Extract only numbers from string using Power Automate flow

In the below screenshot, we can see the extracted number values from the Product ID field in the SharePoint list.

How to extract ONLY numbers from string using Power Automate flow

This is how to extract only numbers from a SharePoint list text column using flow.

Conclusion

So, I hope you get an idea of how to extract only numbers from the string using Power Automate flow. Here, I have explained static and dynamic ways of extracting only numbers from the string values in Power Automate flow with different examples.

You may also like:

>