Are you in need of format numbers without decimals in Power Automate? This Power Automate tutorial will help you format numbers without Decimals using Power Automate.
Scenario:
Recently, I got a requirement to format the numbers without decimals using Power Automate flow. For example, For example, if the value is 60.00% after formatting, it should return the value as 60% without decimal using flow.
Finally, I have to send an email with detailed information about the Product List to the user using the send email (v2) action.
Before creating a flow, we have to create a SharePoint list, so here I am going to use the below SharePoint Product list consisting of,
Column Names | Column Type |
ProductName | default title column |
ProductQuantity | Number column |
ProductPrice | Number column |
ProductStatus | Choice column |
DiscountsInPercentage | Number column |
ProductPriceAfterDiscount | Calculated Column |
Now, we will create a flow to format the DiscountsInPercentage column values from decimal to without decimal using Power Automate flow.
Format a Number without Decimal in Power Automate
Let us see how to format numbers without decimals in Power Automate flow
Follow the below-mentioned steps:
Step-1:
Create an instant cloud flow with the manual trigger. Select a new step and add a Get items action to get all the items from the SharePoint list.
Expand the get items action and configure the required parameters,
- SharePoint site address – select the SharePoint site from the dropdown
- List name – choose the list from the dropdown (I have selected my Product List).
Step-2:
Add a new step, choose the Select data operation, and choose the From Option as a value from dynamic content. Similarly, in the map, enter key and map values from the dynamic content.
Here, I have formatted the Product Price value with the below expression to display the price value in a currency format.
formatNumber(item()?['ProductPrice'],'C0')
To Format a Percentage value without decimals, use the below expression, which formats the value from 60.00% to 60%.
formatNumber(item()?['DiscountsInPercentage'],'0%')
Similarly, ProductPriceAfterDiscount, I have formatted the Product Price value with the below expression to display the price value in a currency format.
formatNumber(float(item()?['ProductPriceAfterDiscount']),'C0')
Step-3:
In this next step, we will create an HTML table by selecting the ‘Create HTML table‘ action from the action triggers.
Next, in the From box, select the ‘output’ from the dynamic content for the select data operation action, and in the Columns box, select Automatic.
body('Select')
Step-4:
Add a compose action to apply the style for the generated HTML table; for that, add the CSS code below.
<style>
table {
border: 1px solid #1C6EA4;
background-color: #EEEEEE;
width: 100%;
text-align: left;
border-collapse: collapse;
}
table td, table th {
border: 1px solid #AAAAAA;
padding: 3px 2px;
}
table tbody td {
font-size: 13px;
}
table thead {
background: #1C6EA4;
border-bottom: 2px solid #444444;
}
table thead th {
font-size: 15px;
font-weight: bold;
color: #FFFFFF;
border-left: 2px solid #D0E4F5;
}
table thead th:first-child {
border-left: none;
}
</style>
Step-5:
- To send an email, select Send an Email (V2) (outlook) action. In The To address, pass the dynamic content user email address.
- Then, in the body, add outputs of the style-composed action and HTML action from dynamic content.
body('Create_HTML_Table')
Outputs('CSS')
Step-6:
Save and test the flow manually by selecting the run flow option. Once the flow runs successfully, like below:
In the screenshot below, we received an Outlook email with the HTML table that has been generated and displays the Product List information in detail.
Conclusion
I hope you get an idea to format numbers without decimals using Power Automate flow.
I have clearly shown you an example of formatting numbers without decimal places, like values from 60.00% to 60%.using the formatnumber() function in Power Automate.
You may also like the following tutorials:
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