web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Round function in powe...
Power Automate
Answered

Round function in power automate?

(0) ShareShare
ReportReport
Posted on by 237

Hi All!

 

I have a float that I need to round to the nearest whole number. For example: 3.480987 will be "3" while 3.7685 should be "4". I can't seem to find a round function. Is there? What are some work-arounds for this if there isn't any... thank you!

 

-bochie

Categories:
I have the same question (0)
  • Verified answer
    ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @Bochie 

    I wish there were a round() expression....

    Please see my example below - I don't see a way to make is less complicated but I wish I could.

    Here is the expression that I used:

    if(greater(Mod(outputs('Compose'),1),0.5),add(int(first(split(string(outputs('Compose')),'.'))),1),first(split(string(outputs('Compose')),'.')))
     
    image.png
     
     
  • Bochie Profile Picture
    237 on at

    Thank you so much @ScottShearer ! Enjoy the weekend 🙂 

  • ScottShearer Profile Picture
    25,290 Most Valuable Professional on at

    @Bochie 

    One small change - I probably should have used GreaterOrEquals() rather than greater()

  • Bochie Profile Picture
    237 on at

    @ScottShearer , yes indeed! Thank you again!

  • lras1202 Profile Picture
    52 on at

    @ScottShearer  Thank you for saving my day today!

  • timothy_bohte Profile Picture
    44 on at

    Thank you for answering this one. I was looking for the rounding option in Power Automate Flow as well. It's still not available in Flow. I hope this is coming soon.

    Untill then, great solution! I got an error that it was a string. To handle this, I put the whole calculation into a Float(). Works as a charm now 🙂 

  • goncaloperes Profile Picture
    85 on at

    Considering that the goal is to round to the nearest integer ("whole number"), this would do the work

     

     

    @{if(greater(sub(float(myNumber), int(formatNumber(float(myNumber), 'F0'))), 0.5), add(int(formatNumber(float(myNumber), 'F0')), 1), int(formatNumber(float(myNumber), 'F0')))}

     

     or 

    @{if(greaterOrEquals(sub(float(myNumber), int(formatNumber(float(myNumber), 'F0'))), 0.5), add(int(formatNumber(float(myNumber), 'F0')), 1), int(formatNumber(float(myNumber), 'F0')))}

     

    Let's see a few examples:

     

    Example 1:

    Using two actions: Compose 3 and Compose 4.

    In Compose 3, one uses as input the number 3.480987.

    In Compose 4, one uses as input the expression

     

     

    @{if(greater(sub(float(outputs('Compose_3')), int(formatNumber(float(outputs('Compose_3')), 'F0'))), 0.5), add(int(formatNumber(float(outputs('Compose_3')), 'F0')), 1), int(formatNumber(float(outputs('Compose_3')), 'F0')))}

     

     

     

     

    goncaloperes_0-1681814187945.png

    This gives the following output:

     

    goncaloperes_1-1681814214221.png

     

    Example 2

    Using two actions: Initialize variable and Compose 5.

    In Initialize variable one uses a float 3.7685 with the name e myNumber. 

    In Compose 5, uses as input the expression

     

     

    @{if(greater(sub(float(variables('myNumber')), int(formatNumber(float(variables('myNumber')), 'F0'))), 0.5), add(int(formatNumber(float(variables('myNumber')), 'F0')), 1), int(formatNumber(float(variables('myNumber')), 'F0')))}

     

     

     

    goncaloperes_2-1681815198666.png

    This gives the following output

    goncaloperes_3-1681815245821.png

    ---

    Example 3

     

    Now let us test the second case, with greaterOrEquals.

    For that, one will use two actions: Compose and Compose 2

    goncaloperes_0-1681822739146.png

    This is the output

    goncaloperes_1-1681822813775.png

     

     

    ---

    Notes:

    • In Power Automate, expressions need to be enclosed within the @{} syntax when added in the "Inputs" field of actions.

    • Relevant read: Use expressions in conditions to check multiple values.

    • If all one wants it to round up a number, one can do the following:

     

     

    @{add(int(formatNumber(Value,'F0')),1)}

     

     



  • trixxxxxxx123 Profile Picture
    2 on at

    For example, if I have a number like 7.978 or 7.890, I would like it to be rounded up to 8.0. However, if the number is 7.776 or 7.678 , I want it to be displayed as 7.7 or 7.6. How can I do this?

  • lewiscarr81 Profile Picture
    14 on at

    @Bochie 

     

    Have you tried

    formatNumber(decimalnumber, 'F2')

     

    Screenshot 2023-07-20 155355.png

    Which Should return your answer to 2dp

    Screenshot 2023-07-20 155410.png

  • aismaili Profile Picture
    9 on at

    All the answers here were very useful to find the best fitting solution for me.

    Let's start with my final solution and then work towards the requested solution of Bochie.

    I am using the following expression to round a float as string to a decimal  with one digit behind the decimal divider:

     

     

    formatNumber(add(float(triggerOutputs()?['body/score']),0.00000000000001),'F1')

     

     

    (background is, that a SharePoint calculated column is handed over to Power Automate as a string, and even if you set it in SharePoint to have one decimal digit, it will always hand over the full float)

     

    This formula is working fine for me, but now let me make it a bit easier for you:

    First, let's assume, the variable <floatVar> is already a float, so we remove the SharePoint calculated field 'score' and replace it with a placeholder, that you will have to replace in your expression:

     

     

    formatNumber(add(<floatVar>,0.00000000000001),'F1')

     

     

     

    and now, let's look at the rule for rounding up or off when next digit is a 5*:

    for me, the requirement was, that a number 3.25 should be rounded up to 3.3, but the default for formatNumber is, that it will round off in that case.

    Therefore, I have to add the smallest possible number, so that it gets a bit more than exactly 3.25 and so it rounds up.

    But if you want to use the default behaviour to have 3.2 in case of 3.25, the formula is even easier:

     

     

    formatNumber(<floatVar>),'F1')

     

     

     

    And now, to finally answer Bochie's question, the easy round function for float/decimal numbers to whole numbers is just to set the number of decimal digits to 0:

     

     

    formatNumber(<floatVar>),'F0')

     

     

     

    Little bonus:

    In all cases, formatNumber will only return a string, even if it looks like a number, so if you intend to do calculations, you need to again convert the resulting string to an int or float like in the following example! 😉

     

     

    int(formatNumber(<floatVar>,'F0'))

     

     

     

    With all these examples and tweaks, I hope everybody is now able to find the ideal solution for your exact use case.

     

    See also this site for a definition of formatNumber expression:

    https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#formatnumber

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard