Do you want to format numbers to decimal places using Power Automate flow? Then, this Power Automate tutorial will show you how to Format Numbers with Decimal Places using Power Automate Flow.
Scenario:
Recently, I got a requirement to format the numbers with decimal places using Power Automate flow. For example, When the user inputs the value 1234, and I want to format the input value with one decimal place, then the output will be 123.4; similarly, for two decimal places, the output will be 12.34.
Here, I will show three examples to format a number with Decimal Places in Power Automate.
In the first example, we will use the Format number action to format a number with a Decimal Place using flow.
In the second example, we will use the format-number function to format a number with Decimal Place using flow.
Finally, I will show you how to get the number value from the SharePoint online list, format it with the Decimal Places, and update the SharePoint list field with formatted decimal value using Power Automate.
Before creating a flow, we have to know what standard formats are available to display a number with decimal places.
The Standard format ‘F’ (Fixed-point)supports the Format Number action and the format-number function in Power Automate and formats the number with decimal places.
Format | Expression | Number | Output |
F | formatNumber(2,’F’) | 2 | 2.00 |
F0 | formatNumber(2,’F0′) | 2 | 2 |
F1 | formatNumber(2,’F1′) | 2 | 2.0 |
F2 | formatNumber(2,’F2′) | 2 | 2.00 |
F3 | formatNumber(2,’F3′) | 2 | 2.000 |
Now, we will create a flow to format a number value with Decimal Places using Power Automate flow.
Power Automate Format Number to Decimal Places
Let us see how we can Format Numbers with decimal places using Power Automate flow.
Example-1: (Using Format Number action)
Here, we will see how to format a number value with decimal places by using the Format Number action with two different formats in Power Automate flow.
- Standard Format
- Custom Format
Step-1:
Create an instant cloud flow, expand the trigger action, and add a Number input as below:
Step-2: (Standard Format)
Add a new step and choose the Format Number action from the action trigger. Provide the required parameters.
- Number – Pass the dynamic content of the number input
- Format – Now choose the Standard format ‘F3’, which formats the input number value with decimal places.
- Locale – Is an option field (Used to format the number)
triggerBody()['number']
Step-3:
Save and Run the flow. Enter the number input and choose the run flow option
Once the flow runs successfully, we can see that the number value is formatted with a decimal value in the expected output section.
Here, I have given the input value as 4.234579 and selected the Fixed Point format F3, so it rounds up and displays the output value as 4.235
Step-4: (Custom Format)
Custom Format – Decimal Point Placeholder uses #.00 format,
Follow the (step-2) in the format number action, in the format option, choose the Custom value and pass the #.00 as highlighted below:
triggerBody()['number']
Save and Run the flow, Here I have entered the input value as 9.2375930.
Once the flow runs successfully, we can see it displays the output value as 9.24.
This is how to format a number value with decimal places by using the Format Number action with two different formats in the Power Automate flow
Example-2: (Using Format Number Function)
Now we will see how to format a number value with decimal places by using the Format Number function in Power Automate flow
Step-1:
Create an instant cloud flow, expand the trigger action, and add a Number input as below:
Step-2:
Add a compose data operation, and pass the below expression to format a number value with decimal places under the Expression tab.
formatNumber(triggerBody()['number'], 'F1')
Where,
- formatNumber – function name
- number – input value
- F1 – Standard Fixed Point format
Step-3:
Save the flow. Enter the number input and choose the run flow option.
Once the flow runs successfully, we can see that the number value is formatted with the decimal place value in the expected output section.
Here, I have given the input value as 2.88 and selected the Fixed point format F1, so it rounds up the value and displays the output value as 2.9
This is how to format a number value with decimal places by using the Format Number function in Power Automate flow
Power Automate Format Number to 2 Decimal Places
Using Power Automate flow, let us see how we can Update the SharePoint list field with a Formatted Number with 2 Decimal Places Value.
In this example, I am going to use the below SharePoint Products list, consisting of,
Column Name | Column Type |
ProductName | default title column |
ProductPrice | Number column |
ProductStatus | Choice column |
ProductPricewith2DecimalPlaces | Text type |
To achieve this, follow the below steps:
Step-1:
Create an automated cloud flow, and select the trigger When an item is created or modified action and provide the required Parameters as highlighted below:
- Site Address – From the dropdown, select the SharePoint site address
- List – Choose the list name from the dropdown. (Here, I have selected my SharePoint Products List)
Step-2:
Add a compose data operation, and pass the below expression to format a number value with the two decimal places under the Expression tab.
formatNumber(triggerOutputs()?['body/ProductPrice'],'#.00')
Where,
- formatNumber – function name
- ProductPrice – SharePoint column internal name
- #.00 – Custom format for fixed point with 2 decimal places
Step-3:
Select an Update item action and configure the required parameters:
- Site Address – Select the SharePoint site address from dropdown
- List – Select the list name from the dropdown. (I have selected my SharePoint Products List)
- ID– Select the ID from the dynamic content value
- Title – From the dynamic content, choose the title value
- ProductPricewith2DecimalPlaces – From the dynamic content, Pass the outputs of the compose data operation, which formats the number value with the two decimal places.
Step-4:
Save the flow. The flow will trigger only when the new item is added or modified to the SharePoint list.
In the below screenshot, you can see that I have added the new item with a Product Price value of $238
Once the flow runs successfully like below:
The number value is formatted with 2 decimal places and updates the values in the SharePoint list ProductPricewith2DecimalPlaces field.
This is how to Update the SharePoint list field with a Formatted Number with 2 Decimal Places Value using Power Automate flow.
Conclusion
I hope you know how to format number decimal places using Power Automate flow.
I have clearly shown you different examples of formatting numbers with decimal places in Power Automate flow.
In the first example, I have explained format numbers with decimal places with Standard Format and Custom Format using Format Number Action in Power Automate.
In the second example, I have explained format numbers with decimal places in Standard Format using the Format Number function in Power Automate.
In the other example, I have explained format numbers with decimal places in Custom Format using the Format Number function and Updated the SharePoint list field with Formatted two decimal places Value using flow.
You may also like:
- Power Automate formatdatetime
- How To Format A Number In Power Automate
- How to Format Number to Percentage 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