Do you want to convert strings to decimal numbers in Power Automate? In this Power Automate tutorial, we will see how to convert a string to a decimal in Power Automate.
Converting a string into a decimal is a common task, especially when dealing with data from different places.
Sometimes, what seems like a decimal number is actually in the form of a text string. This can lead to problems later in your process if you want to work with these numbers. To avoid errors, you need to change these text strings into decimal numbers before doing any calculation with them.
We can change it using two functions i.e., decimal function and float function in Power Automate.
The decimal function and Float function take the value as a string and then convert it into a decimal number or float number.
decimal(<value>)
float(<value>)
Here, we will cover the examples below
- How to convert string to decimal number in Power Automate.
- How to convert string to decimal number dynamically using Power Automate
Convert string to decimal number in Power Automate
Here, we will see how to convert string to decimal number in Power Automate.
Example 1: Using float()
1. Open Power Automate Cloud, then click on +Create -> select Instant Cloud Flow.
Then, provide a flow name and select Manually trigger a flow action. Then click on Create.
Now, you can see the “Manually trigger a flow” action is added to the flow page in Power Automate.
2. We will initialize a string variable; for this, click on +New step -> select Initialize variable action. Then provide the below information:
- Name: Provide the name of the variable
- Type: Provide the type as a string
- Value: Provide the value like below
3. Now, we will convert the string to a decimal number; for this, click on the +New step -> select Compose action. Then provide the below information:
float(variables('str'))
4. Now save and run the flow manually, and you can see the converted string to a decimal number in Power Automate.
Example 2: Using decimal()
1. Open Power Automate Cloud, then click on +Create -> select Instant Cloud Flow.
Then, provide a flow name and select Manually trigger a flow action. Then click on Create.
Now, you can see the “Manually trigger a flow” action is added to the flow page in Power Automate.
2. We will initialize a string variable; for this, click on +New step -> select Initialize variable action. Then provide the below information:
- Name: Provide the name of the variable
- Type: Provide the type as a string
- Value: Provide the value like below
3. Now, we will convert the string to a decimal number; for this, click on the +New step -> select Compose action. Then provide the below information:
decimal(variables('str'))
4. Now save the flow and run the flow manually, and you can see converted string to a decimal number in Power Automate.
This is how to convert the string to a decimal number in Power Automate.
Convert string to decimal number dynamically using Power Automate
Here, we will see how to convert strings to decimal numbers dynamically using Power Automate.
For example, we have a SharePoint list called Product, which contains two columns i.e., Name and Price.
We will convert the price string value to a decimal number. For this, follow the below steps:
1. Open Power Automate Cloud, then click on +Create -> select Instant Cloud Flow.
Then, provide a flow name and select Manually trigger a flow action. Then click on Create.
Now, you can see the Manually trigger a flow action is added to the flow page in Power Automate.
2. We will get items from the SharePoint list; for this, click on the +New steps -> select Get items action. Then provide the below information:
- Site address: Provide the SharePoint site address
- List name: Provide the SharePoint list name
3. Now, we will convert the string to a decimal number; for this, click on +New step -> select Compose action. Then, provide the information below.
- Inputs: Provide the below expression. This will automatically add Apply to each action.
decimal(items('Apply_to_each')?['Price'])
4. Now save the flow and run the flow manually, and you can see that convert the string to a decimal number.
This is how to convert strings to decimal numbers dynamically in Power Automate.
Conclusion
In this Power Automate tutorial, we will see how to convert a string to a decimal number in Power Automate using the decimal() and float() functions.
You may like the following tutorials:
- How to Convert String to Object in Power Automate
- Convert a String to an Array in Power Automate
- Convert String to Integer in Power Automate
- Convert String to Date in Power Automate
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com