cancel
Showing results for
Did you mean:
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

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Hi @Esox76,

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

``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
10 REPLIES 10

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

See if the above helps @Esox76

Helper III

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

Thanks

Community Support

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.

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))``

Best Regards,

Zhi Chen

Helper III

@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

Community Support
Hi @Esox76,

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

``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
Helper III

@v-chenzhi Solution works very well Thank You

Esox

Super User

This blog post solves Round off problems

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.

Frequent Visitor

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.

Announcements

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,453)