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
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)
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'),'')
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.
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
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
Step-2:
Add a new step, choose an Apply to each control, and pass the value from the dynamic content
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)
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'),'')
Step-3:
Save and run the flow once the flow runs successfully like below:
In the below screenshot, we can see the extracted number values from the Product ID field in the SharePoint list.
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:
- How to convert string to Date using Power Automate?
- Replace Commas with New Lines in Power Automate
- How to Extract Numbers from Email Subjects in Power Automate?
- How to Check if a String Contains Numbers in Power Automate?
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.