cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Community Support
Community Support

Re: Dynamically set number of decimals in a flow

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.

View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

Re: Dynamically set number of decimals in a flow

@JohanWP 

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 I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Highlighted
Regular Visitor

Re: Dynamically set number of decimals in a flow

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

Highlighted
Community Support
Community Support

Re: Dynamically set number of decimals in a flow

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.

View solution in original post

Helpful resources

Announcements
FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

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

Users online (3,290)