cancel
Showing results for
Did you mean:
Anonymous
Not applicable

## decimal place

Is it possible to limit a float to 2 decimal place?

2 ACCEPTED SOLUTIONS

Accepted Solutions
Memorable Member

Hi @Anonymous

Limit the float variable no, but you can use an action to transform cutting the others decimals places.

The expression to do this is :

if the float value is in a variable :

also, if is in a action:

In this fuction the is the count of decimal places plus the dot place.

If you need more help, post here.

Hope Have Helped,

Gustavo Moraes

Gustavo Moraes, o astronauta brasileiro do Flow!

Memorable Member

Hi @Anonymous you need to click inside dynamic content to use expression and put that function inside the red square,

like the print below:

OBS: I see the text inside variable is the float value, in the snippet that i post you need to put the Variable Action name, if you have direct value, can remove the literal text "variable"

Best Regards,

Gustvo Moraes

Gustavo Moraes, o astronauta brasileiro do Flow!

15 REPLIES 15
Memorable Member

Hi @Anonymous

Limit the float variable no, but you can use an action to transform cutting the others decimals places.

The expression to do this is :

if the float value is in a variable :

also, if is in a action:

In this fuction the is the count of decimal places plus the dot place.

If you need more help, post here.

Hope Have Helped,

Gustavo Moraes

Gustavo Moraes, o astronauta brasileiro do Flow!

Anonymous
Not applicable

Where do i have to put in that code snipped?

I have a variable as a string.

Thanks

Memorable Member

Hi @Anonymous, i recommend you to use a 'Compose' action.

Look the images:

How i did

After yoiu can use this compose to do your flow.

Result

Hope Have Helped,

Gustavo Moraes

Gustavo Moraes, o astronauta brasileiro do Flow!

Anonymous
Not applicable

almost

Anonymous
Not applicable

Memorable Member

Hi @Anonymous you need to click inside dynamic content to use expression and put that function inside the red square,

like the print below:

OBS: I see the text inside variable is the float value, in the snippet that i post you need to put the Variable Action name, if you have direct value, can remove the literal text "variable"

Best Regards,

Gustvo Moraes

Gustavo Moraes, o astronauta brasileiro do Flow!

Anonymous
Not applicable

Thank you it works!!!

Regular Visitor

@gamoraes You are my hero and if you were present I would buy you lunch! THANK YOU!!

Frequent Visitor

Hi,

To overcome the problem of having a decimal number with only one decimal, simply add an insignificant number to it, like 0,00001.

This way you automatically always have more that 2 decimals.

Here is the formula:

`substring(string(add(triggerBody()['number'],0.000001)),0,add(indexof(string(add(triggerBody()['number'],0.000001)),'.'),3))`
Helper III

This method does not work if You run numbers like. 390.00 or 290.00. I'm getting results 39 ir 29

Here is my formula:

Memorable Member

Hi @LEARN_IT, the problem with your expression is in red, you need to put the length of decimal places(in your case 2)

The correct function to remove decimal with 2 places are

Gustavo Moraes, o astronauta brasileiro do Flow!

One note here, it may be wise to convert it back into a float by adding float() as the last step of the formula.

`float(substring(string(outputs('Get_Running_Total')),0,add(indexof(string(outputs('Get_Running_Total')),'.'),3)))`

Kudo Collector

I posted a solution that rounds a float to hundreths on another thread. The solutions above truncate.

Helper II

the decimal solution worked for me, BUT do you also have a solution for adding the comma in appropriate places?

Kudo Collector

Yup. See my post here. My 2nd post on that thread has the more robust, expanded version.

Announcements

#### Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Check out how to claim yours today!

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (73,413)