Skip to main content

How to Format a Number with Two Decimal Places in Power Automate

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

formatNumber(number, '0.00') shows a number with exactly two decimal places: 3.75 as 3.75, and 3 as 3.00. The result is text, which is right for emails and approvals; to save it to a number column, turn it back into a number with float().

Microsoft's functions reference says formatNumber() will Return a number as a string that's based on the specified format. Its example, formatNumber(1234567890, '#,##0.00', 'en-US'), formats the number as the string "1,234,567,890.00".

The example is the approval flow of the Overtime Timesheet app, which shows each shift's hours to the approver with two decimal places, the way payroll counts them.

Prerequisites​

Step 1: Format the Number​

Wrap the number in formatNumber() with the format '0.00'. In the example, it's the outside of the Hours worked out expression:

Hours worked out → Inputs
formatNumber(div(sub(div(sub(ticks(triggerOutputs()?['body/EndTime']), ticks(triggerOutputs()?['body/StartTime'])), 600000000), coalesce(triggerOutputs()?['body/BreakMinutes'], 0)), 60.0), '0.00')

In the format, each 0 is a digit that's always shown, so '0.00' always has one digit before the point and two after it.

The Hours worked out pane with the expression editor beside it showing the formatNumber expression ending in '0.00'

The Result​

For a shift of 3 hours and 45 minutes, the run's output was "3.75", in quotes because it's text:

The run's Hours worked out: Inputs and Outputs both "3.75"

A whole number keeps its two places: a three-hour shift read Hours: 3.00 in the approval request (How to Approve a Request in the Microsoft Teams Approvals App).

Step 2: Convert It Back to Save It​

A SharePoint Number column needs a number. In Record the decision, the Update item action that saves the decision, Hours turns the text back with float():

Record the decision → Hours
float(outputs('Hours_worked_out'))

The Record the decision pane with its required fields, including Hours set to a float(...) token

The reference describes float(): Convert a string version for a floating-point number to an actual floating point number. The entry's Hours was saved as 3.75.

Other Formats​

The format follows the same pattern for other layouts: Microsoft's example '#,##0.00' adds a thousands separator, and its third argument, 'en-US', sets the locale the separators come from.

Common Mistakes​

MistakeWhat happensDo this instead
Doing arithmetic with the formatted valueIt's textCalculate first, format last
Saving the text to a Number columnIt needs a numberfloat() it first

Troubleshooting​

SymptomLikely causeFix
3.5 instead of 3.50The number wasn't formattedformatNumber(x, '0.00')
Quotes around the value in a runIt's text, as expectedNothing to fix
An error saving to a Number columnText where a number is neededfloat()

FAQ​

Why is the value in quotes in the run?​

Because formatNumber() returns text. The run shows text values in quotes and numbers without them.

Where does the number come from?​

Format the final number only. Here, the hours are worked out from the shift's times first, and formatNumber() is the last step.

Conclusion​

formatNumber(x, '0.00') shows a number with exactly two decimal places, as text. Use it in emails and approvals, and float() it back when a Number column needs it.

Additional Resources​