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

8 REPLIES 8
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.

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 II
Advocate II

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

Highlighted
New Member

Re: Round a Float

@irondinges  your workaround is a perfect solution. Thank you!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Kudoed Authors
Users online (5,105)