Are you trying to convert a string value to a Decimal Number value in Power Automate? This Power Automate tutorial will help to convert a string to a Decimal Number in Power Automate.
Whenever a user enters a decimal number value in a string data type, the Power Automate flow is considered as a text value. It will not be taken as a decimal number value.
To Perform an addition with two decimal values, we require two input values with the number data type.
So the user enters the first input value is 1.2345 with the text data type, and the second input value is 3.2345 with the number data type. While performing the addition, the flow fails.
To overcome this, we have to convert the first input String value from the text data type to a Decimal Number value of the Number data type.
Then, it performs the addition operation with the two decimal input values. So, the flow will run without any errors and display the output value of the two decimal values as expected.
Decimal function in Power Automate
- The Decimal function returns a string containing a decimal number as a decimal number. We can use the decimal function to perform math functions.
- This decimal function is used to wrap any decimal output with the string values.
Below is the syntax of the decimal function:
Now we will create a flow to convert String to a Decimal Number using Power Automate Flow,
How to Convert a String to a Decimal Number in Power Automate
Let us see how to convert a String to a Decimal Number in Power Automate Flow,
1. Create an instant cloud flow, Expand the manual trigger action, and add two input values. The first input value is the text data type, and the second input value with the number data type.
2. To convert the first decimal input value from the text data type to a number data type decimal value, we will use the decimal() function.
Add a compose data operation from the action triggers and pass the below expression.
- decimal – function name
- triggerBody()[‘text’] – first input value
3. We will perform an addition with the two decimal values. (Converted text to number value with the directly passed number value).
For that, select the compose data operation and pass the below expression, which performs the addition of two decimal values with an integer data type.
- add – function name
- outputs(‘Compose’) – first input value (converted from text data type to number data type)
- triggerBody()[‘number’] – second input value
4. Save and Run the flow; enter the two input values and click on the Run flow option.
Once the flow runs successfully, we can see the flow performs an addition and displays the output value as expected.
This is how to convert a string to a decimal number using the decimal() function in Power Automate.
So, I hope now you understand why we need to convert a string value to a decimal number in Power Automate flow.
Using a decimal() function in Power Automate, we can easily convert the string values to a decimal number value, and this supports all the values that are text data types when you expect them to be a number data type in Power Automate.
You may also like:
- Convert a String to an Integer in Power Automate
- Convert String to GUID in Power Automate
- Get File Content using Path in Power Automate
- Convert String to Float 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.