cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

How to get Microsoft flow to approximate correctly

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.

Dividing numbers with flow.PNG

5 REPLIES 5
Highlighted
Responsive Resident
Responsive Resident

Re: How to get Microsoft flow to approximate correctly

Wrap your numbers in float(), that seems to do the trick

 

div(float(11),float(12))

 

Source: https://powerusers.microsoft.com/t5/I-Found-A-Bug/div-function-not-returning-float-number/td-p/60852 

Highlighted
Dual Super User
Dual Super User

Re: How to get Microsoft flow to approximate correctly

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.

div(float(11),12)

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.

div(float(div(mul(11,100),12)),100)


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Frequent Visitor

Re: How to get Microsoft flow to approximate correctly

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.

Highlighted
Dual Super User
Dual Super User

Re: How to get Microsoft flow to approximate correctly

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


-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Community Support
Community Support

Re: How to get Microsoft flow to approximate correctly

 

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.

 

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Users online (9,820)