cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Esox76
Helper III
Helper III

Power automate round up a float value

Hi i have a float value in power automate that i would like to round up. Could someone point me in the right direction 

 

e.g. 0.5 should be 1

1.5 should be 2

 

Thanks in advance Esoxs

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Esox76,

 

Sorry I did not consider the case where the decimal place is 0.

Please try the following formula:

 

if(less(length(split(string(variables('TT')),'.')),int(2)),int(first(split(string(variables('TT')),'.'))),if(less(int(last(split(string(variables('TT')),'.'))),int(5)),int(first(split(string(variables('TT')),'.'))),add(int(first(split(string(variables('TT')),'.'))),1)))

 

 
Best Regards,
Zhi Chen

View solution in original post

9 REPLIES 9

@Esox76 

 

Use the Round function if you want 0.5 to be 1, 1.5 to be 2 - 0.3 to be 0, 1.3 to be 1, etc.

 

Round(NumberDecimalPlaces)

  • Number - Required. The number to round.
  • DecimalPlaces - Required. Number of decimal places to round to. Use a positive value to indicate decimal places right of the decimal separator, a negative value to the left, and zero for a whole number.

Or

 

Use the RoundUp function if you want it to always round up no matter what so 0.3 to be 1, 1.3  to be 2, etc.

 

RoundUp(NumberDecimalPlaces)

  • Number - Required. The number to round.
  • DecimalPlaces - Required. Number of decimal places to round to. Use a positive value to indicate decimal places right of the decimal separator, a negative value to the left, and zero for a whole number.

 

Example:

 

Round(7.9,0) would result in the number 8

Round(7.1,0) would result in the number 7

 

whereas

 

RoundUp(7.9,0) would result in the number 8

RoundUp(7.1,0) would result in the number 8 again

 

Check here: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-round for more info

 

See if the above helps @Esox76 

 

Sorry @poweractivate  but this Round() function is not available in Power Automate

 

Thanks

Hi @Esox76,

 

Do you want to round up a float in power automate flow?

I assume your float have one decimal place and have a test on my side, please try following workaround.

vzhichen_0-1635487179991.png

Here is the expression:

if(less(int(last(split(string(variables('TT')),'.'))),int(5)),int(first(split(string(variables('TT')),'.'))),add(int(first(split(string(variables('TT')),'.'))),1))

vzhichen_1-1635487179995.png

 

      

vzhichen_2-1635487179997.png

 

Best Regards,

Zhi Chen

@v-chenzhi Thanks for this i have tested it but  there is a slight bug in that if my value is 5.0 it calculates it as 6 instead of 5. if it's 4.0 then it ok !

 

Regards Esox

Hi @Esox76,

 

Sorry I did not consider the case where the decimal place is 0.

Please try the following formula:

 

if(less(length(split(string(variables('TT')),'.')),int(2)),int(first(split(string(variables('TT')),'.'))),if(less(int(last(split(string(variables('TT')),'.'))),int(5)),int(first(split(string(variables('TT')),'.'))),add(int(first(split(string(variables('TT')),'.'))),1)))

 

 
Best Regards,
Zhi Chen

@v-chenzhi Solution works very well Thank You 

 

Esox

hemrhk
Super User
Super User

This blog post solves Round off problems

https://365stack.in/index.php/2022/01/01/how-to-round-up-down-decimal-in-power-automate/ 

 

Follow 365 Stack for more updates.

JRockO
New Member

I'm a little late to the game, but you can use the "formatNumber(...)" expression in PowerAutomate to accomplish this. 

 

I haven't done extensive testing to confirm proper rounding for large decimals, but 1.5 becomes 2 when using int(formatNumber(1.5, '0')).

 

Note: '0' is the string used for the number format.  You could also use '#' but I like to use '0' since it's a number and seems more straight forward when reading it.

Thank you Zhi, everything else I tried (and mentioned here) either doesn't work or always rounds down. I will test some more to be sure, but your solution appears to work well. Crazy that there isn't a more straightforward solution such as RoundUp() function that works, but a very impressive workaround.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (1,952)