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

Wrong value for calculation

Hi, I have a calculation that is supposed to return the 'next' sales target (they are rewarded for each additional 10% they achieve over a base target)

 

The formula:
int(string(mul(items('Get_each_FD_to_update')['new_target'],add(div(add(outputs('multiplier'),1),10),1))))

 

With the inputs of 5000 and 27 for 'new_target' and 'multiplier' respectively I get a result of 15000 but it should be 19000

 

Working inside out it should be
27+1 = 28
28/10 = 2.8
2.8+1 = 3.8

5000 * 3.8 = 19000

convert to string

convert to int

 

even if I remove the int(string( part it still give the wrong answer. I have also tried wrapping it in numberFormat(formula, '0') instead. What is going on here?

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Dual Super User
Dual Super User

Hi @Carrotor,

 

Since your using decimals can you try using float?

 

Try this expression instead:

 

mul(float(items('Get_each_FD_to_update')['new_target']), add(div(add(float(outputs('multiplier')), 1), 10),1))

 

View solution in original post

2 REPLIES 2
Expiscornovus
Dual Super User
Dual Super User

Hi @Carrotor,

 

Since your using decimals can you try using float?

 

Try this expression instead:

 

mul(float(items('Get_each_FD_to_update')['new_target']), add(div(add(float(outputs('multiplier')), 1), 10),1))

 

Just as this came though I found the same(ish) solution through trial and error. It would appear that dividing two integers will always give an integer result which sounds like something I half remember from a computer science class I took 20 years ago. the final formula I ended up with was:

 

formatNumber(mul(items('Get_each_FD_to_update')['new_target'],add(div(add(outputs('multiplier'),1),float('10')),1)),'0')
 
I figure as the 2 variables are explicitly integers and the result needs to be an integer too, wrapping the 10 in the float seemed most economical.

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

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