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

Converting a decimal to integer

Hello. I have a form where employees fill out a microsoft form providing information about gifts they have giving. 

 

This includes the value of the gift. In the form I have said to do whole numbers to avoid issues with decimals but some people still put the value of their gift as a decimal - eg $164.95. 

 

When this goes through the flow (which sends an email to their manager seeking approval for this gift) it can't convert this value to an integer like the whole number responses.

 

This is the flow composing the value from the form and then converting it to an integer to be used later

Power_Flow_Your_2-1660891939445.png

 

This is the result if the value from the form has a decimal

 

Power_Flow_Your_1-1660891924979.png

 

Is there a fix that allows me to maybe just tweak the 'Compose Int value' expression to allow decimals to go through just as easily as whole numbers?

 

Thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions
MarconettiMarco
Super User
Super User

Hello @Power_Flow_Your ,

I agree with @GeorgiosG , you should consider to round the decimal number:

MarconettiMarco_1-1660903424578.png

 

Just for your reference, I've created the Float "varIntDecimal" variable, then added a "Compose" action putting the following expression:

if(greaterOrEquals(Mod(variables('varIntDecimal'),1),0.5),add(int(first(split(string(variables('varIntDecimal')),'.'))),1),first(split(string(variables('varIntDecimal')),'.')))

 So, in my case the output is "12":

MarconettiMarco_2-1660903458515.png

 

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

BR,

Marco

View solution in original post

4 REPLIES 4
GeorgiosG
Super User
Super User

HI @Power_Flow_Your ,

 

you can try splitting your input with:

first(split(triggerBody()['text'],'.'))
 
Or use "," as separator and use the first .
 
Maybe you should also consider rounding the number up:

 

Happy to help.
If I have answered your question, please mark your post as Solved.
MarconettiMarco
Super User
Super User

Hello @Power_Flow_Your ,

I agree with @GeorgiosG , you should consider to round the decimal number:

MarconettiMarco_1-1660903424578.png

 

Just for your reference, I've created the Float "varIntDecimal" variable, then added a "Compose" action putting the following expression:

if(greaterOrEquals(Mod(variables('varIntDecimal'),1),0.5),add(int(first(split(string(variables('varIntDecimal')),'.'))),1),first(split(string(variables('varIntDecimal')),'.')))

 So, in my case the output is "12":

MarconettiMarco_2-1660903458515.png

 

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

BR,

Marco

@Power_Flow_Your ,

you can use also the following expression, it's much easier:

formatNumber(variables('varIntDecimal'),'#0')

 

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

BR,

Marco

Power_Flow_Your
Frequent Visitor

Thank you @MarconettiMarco  and @GeorgiosG . This has worked perfectly! 🙂 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (3,129)