cancel
Showing results forย
Did you mean:ย
Regular Visitor

## Dynamically set number of decimals in a flow

Hello!

I am building a flow and one part of it is converting a number in string format (like 5) to have two decimals (5.00). If the number was always a whole number, i could have done something like "hard coding" the zero decimals. But in some scenarios the number will have one decimal already when it enters the flow (like 5.5). In that case i would like the result to be 5.50. To make it a little bit more "complex" it can sometimes have two decimals already when it enters the flow (like 5.55). In that case i would not want to add any decimals to the number. The number will never have more than two decimals when it enters the flow.

So i would like to create some kind of dynamic expression to support these scenarios, the value should always have two decimals, and depending on the number that enters the flow (in other words how many decimals it already has, it could be to add 2, 1 or 0 decimals to it.

Hope i made the problem formulation clear, any input would be greatly appreciated!

//JWP

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support

Hi @JohanWP ,

It seems that your problem has been solved, please go ahead and mark the post as solved by clicking โAccept as Solutionโ so that this thread will be marked for other users to easily identify!

Best regards,

Alice

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 REPLIES 3
Super User III

I am unaware of any way to accomplish your goal in Power Automate.

You might want to suggest it in the Power Automate Ideas if it isn't already there.

If you like my response, please give it a Thumbs Up.

Scott
Regular Visitor

The workaround i came up with is to check the total length of the string and comparing it with the position (lastIndexOf) of the decimal character. With the position of the decimal sign and total string length known i can define the number of decimals with an if expression

//JWP

Community Support

Hi @JohanWP ,

It seems that your problem has been solved, please go ahead and mark the post as solved by clicking โAccept as Solutionโ so that this thread will be marked for other users to easily identify!

Best regards,

Alice

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Announcements

Check out the new Process Advisor community forum board!

#### Microsoft Business Applications Summit sessions

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

Top Solution Authors
Top Kudoed Authors
Users online (17,326)