2 Various Ways to Convert String to Decimal in Power Automate

When working in Power Automate, you’ll often need to convert data between different types. One common scenario is converting a string to a decimal. This is especially useful when dealing with numeric data stored as text, such as prices, quantities, or financial data extracted from a SharePoint list or Excel file.

For example, imagine you have a flow that processes order details from a SharePoint list where the price column is stored as a string. You’ll need to convert that string into a decimal to perform calculations like summing the total or applying discounts. Power Automate won’t treat the value as a number without this conversion, leading to errors or unexpected results.

In this tutorial, I will tell you how to convert string to decimal in Power Automate.

Convert String to Decimal in Power Automate

We can achieve this using two functions: float() and decimal(). Both functions serve similar purposes but have slight differences in behavior:

  • float(): Converts a string into a floating-point number. This is useful when you need a number with decimal precision.
  • decimal(): Converts a string to a decimal value with control over the number of decimal places.

Let’s see with the help of an example:

Example 1: [Convert String to Decimal in Power Automate Using float() Function]

Suppose you have a string value “49.99” that represents a price. Before performing any calculations (applying discounts), you must convert the string to a decimal format in Power Automate.

1. In Power Automate, create an Instant Cloud Flow by Manually trigger a flow.

power automate convert string to decimal number

2. Add an Initialize Variable action for storing string and provide below parameters:

  • Name: varInputString
  • Type: String
  • Value: 49.99
power automate convert string to decimal

3. Add a compose action and provide the below expression:

float(variables('varInputString'))
convert string to decimal power automate

4. Add another Compose action to apply a 10% discount:

mul(outputs('Compose'), 0.9)
How to convert string to decimal number Microsoft power automate

Save your flow and run it manually. Check the output of the Compose actions:

  • The first Compose will show the decimal:
How to convert string to decimal number power automate
  • The second Compose will show the discounted:
Convert String to Decimal in Power Automate Using float() Function

Example 2: [Convert String to Decimal in Power Automate Using decimal() Function]

Imagine you have a SharePoint list named Orders that contains a Price column. The Price column stores numeric values as strings (e.g., “199.99”). You want to create a flow in Power Automate to process these order details and convert the string values into decimals.

power automate flow convert string to decimal

Now follow the below steps:

1. Create an Instant Cloud Flow with the ‘Manually trigger a flow’ trigger. Then, add the ‘Get items‘ action to retrieve data from the SharePoint list and provide the following parameters:

  • Site Address: Select or enter the URL of your SharePoint site.
  • List Name: Select the name of your SharePoint list (Orders).
convert string to decimal in power automate

2. Add a ‘Compose’ action to display the price. Then, provide the price from the dynamic content of the ‘Get items’ action.

It will automatically add a ‘For each’ loop.

Microsoft power automate convert string to decimal

3. Add another compose action and provide the below expression:

decimal(item()?['Price'])
Microsoft power automate convert string to decimal number

Save your flow and run it manually. Review the output of the Compose actions:

  • The first Compose shows the price in string format.
Convert string to decimal number dynamically using Power Automate
  • The second Compose shows the price in decimal format.
How to Convert String to Decimal in Power Automate

Conclusion

In this tutorial, we learned how to convert a string into a decimal in Power Automate, a crucial step when working with numeric data stored as text, such as prices or quantities. We explored two functions, float() and decimal(), and saw how each can convert a string to a decimal. Through practical examples, we demonstrated how to use these functions to process data, apply discounts, and work with data from a SharePoint list.

You may like the following tutorials:

>
Download User registration 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 Power Platform Tutorial PDF

Download 120 Page FREE PDF on Microsoft Power Platform Tutorial. Learn Now…