Do you want to convert decimal to integer in Power Automate? In this Power Automate tutorial, we will see how we can convert decimals to integers or whole numbers.
Here, we will cover the topics below
- How to convert decimal to integer using Power Automate expression
- How to convert decimal to integer using Power Automate custom format
- How to convert decimal to integer using Power Automate standard format
- How to remove decimal places in Power Automate
- How to convert decimal to integer dynamically in Power Automate
Power Automate convert decimal to integer
Convert decimal to an integer using Power Automate expression
Here, we will see how to convert a decimal to an integer using the Power Automate expression.
For example, we have a decimal number, i.e. 12.89, and we need to convert it to a whole number, so the result will be 13.
Now, let’s create a flow that will convert decimals to integers in Power Automate.
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. Initialize a variable to store decimal numbers; for this, click on the +New step and select the Initialize variable action. Then provide the below information:
- Name: Provide the name of the variable
- Type: Provide the type as Float
- Value: Provide the decimal number
3. Next, we will convert the decimal number to an integer; for this, click on +New step -> select Compose action. Then provide the below information:
- Inputs: Provide the below expression:
if(greaterOrEquals(Mod(variables('varDecimal'),1),0.5),add(int(first(split(string(variables('varDecimal')),'.'))),1),first(split(string(variables('varDecimal')),'.')))
4. Run the flow manually; you can see the decimal number converted to a whole number.
This is how to convert a decimal number to an integer in Power Automate.
Convert decimal to an integer using Power Automate custom format
Here, we will see how to convert decimal to integer using Power Automate Custom format.
We will see two methods to use a custom format to convert decimal to integer in Power Automate.
- Format number action
- Format number function
For example, we have a decimal number 12.89, and we will convert it into a whole number, i.e. 13. To do this, we will use the custom format, i.e. # or #0.
Method 1: Format Number action
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. Initialize a variable to store decimal numbers; 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 Float
- Value: Provide the decimal number
3. Now, we will convert the decimal to a whole number; click on the +New step -> select Format Number action. Then provide the information below
- Number: Select the number from dynamic content.
- Format: provide the format as #.
4. Now, run the flow manually, and you can see the decimal number is converted to a whole number.
Method 2: Format number function
Here, we will see how we can use the custom format in formatNumber() to convert decimal to whole numbers in Power Automate.
Add the Compose action instead of the Format number action in the above flow. Then provide the information below
- Inputs: Provide the below expression:
formatNumber(variables('varDecimal'), '#')
or
formatNumber(variables('varDecimal'), '#0')
Now if I run the flow, you can see the decimal number is converted to an integer.
This is how to convert decimal to integer using Power Automate Custom format.
Convert decimal to integer using Power Automate standard format
Here, we will see how to convert decimal to integer using Power Automate standard format.
We will see two methods to use a standard format to convert decimal to integer in Power Automate.
- Format number action
- Format number function
For example, we have a decimal number 12.89, and we will convert it into a whole number, i.e., 13. To do this, we will use the standard format, i.e. N0.
Method 1: Format Number action
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. Initialize a variable to store decimal numbers; for this, click on +New step and select the Initialize variable action. Then provide the below information:
- Name: Provide the name of the variable
- Type: Provide the type as Float
- Value: Provide the decimal number
3. Now, we will convert the decimal to a whole number; for this, click on the +New step -> select Format Number action. Then provide the information below
- Number: Select the number from dynamic content.
- Format: provide the format as N0.
4. Now run the flow manually, and you can see the decimal number is converted to a whole number.
Method 2: Format number function
Here, we will see how we can use the standard format in the formatNumber() function to convert decimal to whole numbers in Power Automate.
Add the Compose action instead of the Format number action in the above flow. Then provide the information below
- Inputs: Provide the below expression:
formatNumber(variables('varDecimal'), 'N0')
Now, if I run the flow manually, you can see the decimal number is converted to an integer.
This is how to convert decimal numbers to Whole numbers in Power Automate.
Convert decimal to integer dynamically in Power Automate
Here, we will see how to convert decimal numbers from Sharepoint lists to integers in Power Automate.
For example, we have a Product list containing 2 columns: Name(Single line of text) and Price (Number).
We will convert the price values that are in decimal numbers, which will convert it into 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.
Now you can see the “Manually trigger a flow” action is added to the flow canvas.
2. Next, we will get 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, we will convert the decimal number to an integer; for this, click on +New step -> select Format Number action. Then provide the below information:
- Number: Select the Price column from dynamic content. It will automatically add Apply to each action to the flow.
- Format: Select Enter custom format, then provide the format as N0.
4. Now, run the flow manually, and you can see the decimal numbers are converted to whole numbers.
This is how to convert the decimal to whole number using power Automate dynamically.
How to remove decimal places in Power Automate
Here, we will see how we can remove decimal places in Power Automate.
For example, we have a decimal number 12.89, and we will convert it into a whole number i.e., 12.
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.
Now you can see the Manually trigger a flow action is added to the flow canvas.
2. Initialize a variable to store decimal numbers; for this, click on the +New step and select the Initialize variable action. Then provide the below information:
- Name: Provide the name of the variable
- Type: Provide the type as Float
- Value: Provide the decimal number
3. Now, we will remove the decimal places; click on Add an action -> select Compose action. Then provide the below information:
- Inputs: Provide the below expression
substring(string(variables('varDecimal')),0,add(indexof(string(variables('varDecimal')),'.'),0))
4. Now, run the flow manually, and you can see the decimal places are removed from the decimal number.
This is how to remove decimal places in Power Automate.
Conclusion
In this Power Automate tutorial, we saw how to convert a decimal to an integer using Power Automate. We saw a few examples of “Power Automate convert decimal to integer”
You may also like:
- Convert a Number to Rounding UP or Down in Power Automate
- Convert an Integer to an Array in Power Automate
- Convert Value to String in Power Automate
- Convert String to Date for SharePoint list using Power Automate
- Convert Number to Date 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