cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Debuchi
Level: Powered On

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
SCTdan
Level 8

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 

Super User
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.
Debuchi
Level: Powered On

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.

Super User
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.
Community Support Team
Community Support Team

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

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 75 members 3,465 guests
Please welcome our newest community members: