Easiest Way to Convert a String to a Decimal Number in Power Automate

Have you ever needed to do calculations in Power Automate but realized your number is stored as text? That happened to me recently while working on a leave management application. In one of the flows, when someone applied for leave with a half-day option, the system stored it as text instead of a number.

This created a problem because I needed to accurately calculate the total leave days. After one change, I successfully converted the string into a decimal, which worked perfectly!

In this tutorial, I will tell you how to convert a String to a Decimal Number in Power Automate.

Decimal Function in Power Automate

The decimal function in Power Automate is used when you want to convert a number or text into a decimal format. It’s helpful if you’re working with values that need precise calculations, like money, measurements, or percentages.

Syntax:

decimal('<value>')
Decimal Function in Power Automate
  • Input: You can give it a number or a string ( “12.345”).
  • Output: It will give you a proper decimal value (12.345).

Convert a String to a Decimal Number in Power Automate

Suppose you have a SharePoint list called “Orders” that tracks customer orders. One of the columns, “Price,” is stored as a string.

String to a Decimal Number in Power Automate

You aim to calculate the Total Cost by multiplying the item price by the Quantity (a number column). Since “Item Price” is a string, you need to convert it to a decimal number before performing the calculation.

Now follow the below steps:

1. Create an Automated Cloud Flow using the SharePoint connector’s ‘When an item is created‘ trigger. Select the SharePoint site where your ‘Orders‘ list is located, and choose the ‘Orders‘ list.

power automate string to number

2. Add an “Initialize variable” action to store the item price as a decimal.

  • Name: varItemPrice
  • Type: Float
power automate convert string to number

3. Use the Set Variable action to assign the decimal value to the varItemPrice variable.

  • Name: select varItemPrice
  • Value:
decimal(triggerBody()?['Price'])

This converts the string value in the “Price” column to a decimal number.

power automate convert text to decimal

4. Add a “Compose” action to calculate the total cost and provide the below expression:

mul(triggerBody()?['Quantity'],variables('varItemPrice'))
convert string to decimal using power automate

5. Use the “Update item” action to update the “Total Cost” column in the SharePoint list with the calculated value.

  • Site Address: Select the SharePoint site address in your Orders list.
  • List Name: choose the ‘Orders’ list from the drop-down.
  • Id: Provide ID from dynamic content when an item is created.
  • Total Cost: Set the Total Cost column to the output of the Compose action.
How to Convert a String to a Decimal Number in Power Automate

Save the flow and run it manually. Then, go to the SharePoint list and add a new item.

How to Convert a String to a Decimal Number Power Automate

After the flow runs successfully, refresh the SharePoint list. The value will be updated in the ‘Total Cost’ column.

Convert a String to a Decimal Number in Power Automate

Conclusion

In this tutorial, I told decimal functions in Power Automate and how to convert a string to an integer in Power Automate, which is useful when working with data that needs numerical calculations.

>

Build a High-Performance Project Management Site in SharePoint Online

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

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…