01-08-2020 11:13 AM
I was looking for a Power Automate equivalent to Excel's Round() function, when I stumbled upon this - at first it looked great, but after some testing, I have found two issues:
1. it cannot handle numbers that have fewer decimal places than you're trying to round off to (i.e. the number of decimal place you check against in the "Do until" action)
2. it doesn't correctly handle numbers where the first decimal place is a 0
enter 1.1 (where the Do until action is trying to round to 2 decimal places)
results in the flow failing
the result returned by the flow is 1.126544
the correct result should have been 1.012654
In an attempt to fix the two issues mentioned, I stumbled upon a third issue - the approach taken to rounding is basically not correct, as it always rounds every number in reverse one by one.
This issue can be seen if you try to round 0.4949 to two decimal places - the correct result is 0.49, however the flow will return 0.50.
The reason why the flow returns 0.50 is that it always rounds the last decimal place:
- Step 1: 0.4949 is rounded to 0.495
- Step 2: 0.495 is rounded to 0.50