I notice that when I use the div function to do a division of two numbers, Microsoft Flow approximates the result to an integer.
But the problem is that the approximation doesn't follow what I am used to in Mathematics.
For example, the expression div(11,12) produces zero(0) as the result instead of 0.92 or 1 if approximating to the nearest whole number.
How can I change this or workaround this limitation?
Thanks in advance.
Wrap your numbers in float(), that seems to do the trick
The problem is that your inputs are both integers so it calculates the result rounded down to the nearest integer. If you make sure one of the numbers is a whole number then it will give you about 6 decimal places.
If you want to control the number of decimals then multiply by the number of decimals you want and then eventually divide by the same number. But it will still round down.
The problem I have with Flow is that it approximates or rounds the result (0.916) to zero (0)
For instance, div(13,14) produces zero(0) as the result instead of approximately 1.
For my scenario, I want the result to be a whole number but the correct one.
For instance, 275/12 or div(275, 12) should be approximately 23 but flow produces 22 as the result.
For that you'll need to use MOD() and an If statement to control the rounding. Flow will always Round down to the nearest number. Something like this should work
if(Mod(float(11),12) > .49,div(float(11),12)+1,div(float(11,12))
Hi @Debuchi ,
Have you had an opportunity to apply Pstork’s recommendations to adapt your Flow?
Were the suggestions above able to help you with your issue? Please take a try.
Features releasing from October 2020 through March 2021
We are excited to announce the launch of Power Virtual Agents Community. Check it out now!
We've updated and improved the layout and uploading format of the Power Automate Cookbook!
Fill out a quick form to claim your user group badge now!