Do you want to convert the percentage to a whole number in Power Automate? In this Power Automate tutorial, we will see how to convert percentage to whole number in Power Automate.
Here, we will cover the below example in Power Automate
- How to convert percentages to whole numbers in Power Automate
- How to dynamically convert percentages to whole numbers in Power automate
- How to calculate percentages and then convert them into Whole numbers in Power Automate.
How to convert percentages to whole numbers in Power Automate
Here, we will see how to convert percentage to whole number in Power Automate.
For example, we have a percentage i.e. 50%, and I need to convert it to a whole number i.e. 1. The calculation is 50/100 =0.5; now convert to a whole number i.e., 1.
1. Open Power Automate Cloud, then click +Create -> select Instant Cloud Flow.
Then, provide the flow name and select Manually trigger a flow action. Click on Create.
You can see the “Manually trigger a flow” action is added to the flow canvas.
2. Initialize a variable to store percentage; for this, click on +New step, and select Initialize variable action. Then provide the below information:
- Name: Provide the name of the variable
- Type: Provide the type as a string
- Value: Provide the number with a percentage symbol
3. Now, we will remove the percentage symbol; for this, click on +New step -> select Compose action. Then provide the below information:
- Inputs: Provide the below expression
int(replace(variables('Percentage'),'%', ''))
4. We will divide the number with 100 to convert the percentage to decimal; for this, click on +New step -> select Compose action. Then provide the below information:
- Inputs: Provide the below expression:
div(float(outputs('Compose')), 100)
5. We will convert the decimal to whole number; for this, click on +New step -> select Format number action. Then provide the below information:
- Number: Select the output from dynamic content.
- Format: Provide the format as #0
6. Now run the flow manually, and you can see the percentage value you have provided is converted to a whole number.
This is how to convert the percentage to a whole number in Power Automate.
How to dynamically convert percentages to whole numbers in Power automate
Here, we will see how to convert the percentage value from a SharePoint list to a whole number in Power Automate.
For example, we have a SharePoint list called Products, which contains 3 columns i.e. Name, Price, and Discount. In the discount column, the number is formatted in Percentage. So we will get the items and convert the discount percentage to the whole number.
1. Open Power Automate Cloud, then click on +Create -> select Instant Cloud Flow.
Then, provide the flow name and select Manually trigger a flow action. Click on Create.
You can see the “Manually trigger a flow” action is added to the flow canvas.
2. Now get the items from the SharePoint list, for this, click on the +new step -> select Get items action. Then provide the below information:
- Site address: Provide the SharePoint site address
- List name: Select the List.
3. As the percentage in Power Automate comes as decimal, so, we just need to convert it to a whole number, for example, 90% -> 0.9.
Now we will convert the decimal to the whole number; for this, click on the +New step, select Format number action, and then provide the below information:
- Number: Select the discount column from dynamic content
- Format: Provide the format #0
4. Now run the flow manually; you can see the percentages are converted to whole numbers.
This is how to convert the percentage to the Whole number dynamically in Power Automate
Calculate percentages and then convert them into Whole numbers in Power Automate
Here, we will see how to calculate the percentages and then convert them into Whole numbers in Power Automate.
For example, I will take the same Product list from SharePoint. here we will first calculate discounts on Product prices, and then we will get the price after the discounts. At last, we will convert the price to a Whole number.
To do this, follow the below steps
1. Open Power Automate Cloud, then click on +Create -> select Instant Cloud Flow.
Then, provide the flow name and select Manually trigger a flow action. Click on Create.
Now you can see the “Manually trigger a flow” action is added to the flow canvas.
2. Now get the items from the SharePoint list; for this, click on the +new step -> select Get items action. Then provide the below information:
- Site address: Provide the SharePoint site address
- List name: Select the List.
3. Next, Add an Apply to each action and then provide the value from the previous step. Now, we will multiply the price with the discount column; for this, click on Add an action and select Compose action.
Then provide the below information:
- Inputs: Provide the below expression:
mul(items('Apply_to_each')?['Price'],items('Apply_to_each')?['Discount'])
4. Now we will subtract the original price – discount price = After discount price; for this, click on Add an action, select Compose action. Then provide the below information:
- Inputs: Provide the below expression:
sub(items('Apply_to_each')?['Price'],outputs('Compose'))
5. Now we will convert the decimal value to a whole number; for this, click on Add an action -> select Format number action. Then provide the below information:
- Number: Select the output from dynamic content
- Format: Provide the format as ‘#0’
6. Now run the flow manually, and you can see the percentage of price is converted to integer.
This is how to calculate percentages and convert them into Whole numbers in Power Automate.
Conclusion
In this Power Automate tutorial, we saw how to convert a percentage to a whole number in Power Automate.
You may also like:
- Convert a Number to Hexadecimal in Power Automate
- Format Number Thousand Separator in Power Automate
- How to Convert Number to Date in Power Automate?
- Convert String to Integer 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