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

Round a Float

I need to round the value of a number that the flow will get from a file property.

What I want is to get this float x.yz and tranform it into x.00 (or an integer).

 

I have tried to use Int() but it seems it doesn't work.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Dual Super User III
Dual Super User III

Re: Round a Float

Hi @MLM 

 

Please see the screenshot below:

int.PNG

Expression:

int(first(split(string(variables('ee')),'.')))

This converts the float to string and extracts the part before the decimal and then converts that to int. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

7 REPLIES 7
Highlighted
Dual Super User III
Dual Super User III

Re: Round a Float

Hi @MLM 

 

Please see the screenshot below:

int.PNG

Expression:

int(first(split(string(variables('ee')),'.')))

This converts the float to string and extracts the part before the decimal and then converts that to int. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

View solution in original post

Highlighted
Frequent Visitor

Re: Round a Float

This works.

Great Thank you!


@yashag2255 wrote:

Hi @MLM 

 

Please see the screenshot below:

int.PNG

Expression:

int(first(split(string(variables('ee')),'.')))

This converts the float to string and extracts the part before the decimal and then converts that to int. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!


 

Highlighted
Advocate I
Advocate I

Re: Round a Float

This is a ridiculous workaround. Why doesn't MS Flow just have Round functions built-in? I have to instantiate TWO variables and have a five nested function calls? Absolutely absurd.

Highlighted
Helper V
Helper V

Re: Round a Float

absolutely agree with this.. i'm dealing with excel datetime columns which already provides an excellent amount of confusion with their serialized time. Seems like the only way to convert it to an understandable datetime for flow, I have to do something similar to this..
having to convert a floating point to a string and then back to int and float is mindbogglingly absurd.

 

The way datatypes are being dealt with is causing so much annoyance and frustrations 😕 

 

/rant 

Highlighted
Dual Super User III
Dual Super User III

Re: Round a Float

Hi @hjaf , And folks visiting this thread now, 

 

A new action named Format Number has been introduced in Power Automate that can be directly used now to format a number (decimals/ currency/ commas etc). You might want to check that out as well. 

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Highlighted
Frequent Visitor

Re: Round a Float

This not a solution! This only can be good, if you want a trunc function. I don't know how to deal with this.

Highlighted
Advocate I
Advocate I

Re: Round a Float

I worked around this ridiculous issue by doing a manual round up by addition.

1. Divide your number

2. Add 0.5 (if you want to round to nearest) or 0.9999 (if you want to round up, as I did in my case. Will have to configure based on your data/accuracy desired)

3. Convert to int, which will chop off everything beyond the decimal.

 

My use case for this was to calculate how many SMS's a message will split into (as there is a limitation of 153 characters), and it was important for me to have 154 characters become 2 SMS's (round up).

Helpful resources

Announcements
secondImage

August 2020 CYST Winners!

Check out the winners of the recent 'Can You Solve These?' community challenge!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

thirdimage

Power Automate Community User Group Member Badge

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

Top Kudoed Authors
Users online (5,456)