Do you need to format a number to a percentage in Power Automate? Then, this Power Automate tutorial will help you format a number to a percentage with different examples.
Scenario:
Recently, I got a requirement to format a percentage using Power Automate flow. Here I will show three different examples to format a number to percentage in Power Automate.
In the first example, we will see how to use the Format number action to format a number to a percentage using flow.
In the second example, we will see how to use the format-number function to format a number to a percentage using flow.
Finally, I will show you how we can get the number value from the SharePoint online list, format it to the percentage value, and update the formatted percentage value to the SharePoint list field using Power Automate.
Before creating a flow, we have to know what standard formats are available to display a number as a percentage. The Standard format ‘P’ supports the Format Number action and the format-number function in Power Automate.
Format | Expression | Number | Output |
P | formatNumber(0.1,’P’) | 0.1 | 10.00 % |
P0 | formatNumber(0.1,’P0’) | 0.1 | 10 % |
P1 | formatNumber(0.1,’P1’) | 0.1 | 10.0 % |
P2 | formatNumber(0.1,’P2’) | 0.1 | 10.00 % |
P3 | formatNumber(0.1,’P3’) | 0.1 | 10.000 % |
Now, we will create a flow to format a number value to a percentage value using Power Automate flow.
How to Format Number to Percentage in Power Automate
Let us see how to format a number value to a percentage value in Power Automate flow,
Example-1:(Using Format Number action)
Here, we will see how to format a number value to a percentage value by using the Format Number action 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 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 ‘P0’, which formats the number value and displays the value in a percentage format.
- Locale – a locale that is used to format the number (optional field)
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 to a percentage value in the expected output section.
Here, I have given the input value as 0.8 and selected the Percentage format P0, so it displays the output value as 80%.
This is how to format a number value to a percentage value by using the Format Number action in Power Automate flow.
Example-2:(Using Format Number function)
Now we will see how to format a number value to a percentage value 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 to a percentage value under the Expression tab.
formatNumber(triggerBody()['number'], 'P')
Where,
- formatNumber – function name
- number – input value
- P – Standard Percentage 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 to a percentage value in the expected output section.
Here I have given the input value as 0.3 and selected the Percentage format P, so it displays the output value as 30.00%.
This is how to format a number value to a percentage value by using the Format Number function in Power Automate flow.
Example-3:(Update SharePoint list field with Formatted Percentage Value)
Let us see how we can Update the SharePoint list field with Formatted Percentage Value using Power Automate flow.
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 |
Discounts | Number column |
DiscountsInPercentage | Text column |
To achieve this, follow the below steps:
Step-1:
Create an automated cloud flow, and choose the trigger When an item is created or modified action from action triggers. Configure 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 to a percentage value under the Expression tab.
formatNumber(triggerOutputs()?['body/Discounts'],'P0')
Where,
- formatNumber – function name
- Discount – SharePoint column internal name
- P0 – Standard Percentage format
Step-3:
Select an Update item action from the action triggers and provide the required parameters:
- Site Address – From the dropdown, select the SharePoint site address
- List – Choose the list name from the dropdown.
- ID– Select the ID from the dynamic content value
- Title – From the dynamic content, choose the title value
- DiscountsInPercentage – Pass the outputs of the compose data operation, which formats the number value to the percentage value.
Step-4:
Save the flow. The flow will trigger only when the new item is added or modified to the SharePoint list.
Here, I have added the new item with a discount value of 0.5, as highlighted below:
Once the flow runs successfully, like below:
We can see that the number value is formatted to a percentage value and updates the values in the SharePoint list DiscountsInPercentage column.
This is how to Update the SharePoint list field with Formatted Percentage Value using Power Automate flow.
Conclusion
I hope you know how to format a number to a percentage using Power Automate flow. Here, I have done three different examples; in the first example, I have shown you how to format a number to a percentage using the Format Number action.
In the second example, I have shown you how to format a number to a percentage using the Format Number function.
In the other example, I have shown you how to Update the SharePoint list field with Formatted Percentage Value using Power Automate flow.
You may also like:
- The DateTime String must match ISO 8601 format error in Power Automate
- Format Numbers with Leading Zeros Using Power Automate
- How to format a number as currency 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