topic Dynamically set number of decimals in a flow in General Power Automate Discussion
https://powerusers.microsoft.com/t5/General-Power-Automate/Dynamically-set-number-of-decimals-in-a-flow/m-p/426332#M43200
<P>Hello!</P><P> </P><P>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.</P><P> </P><P>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.</P><P> </P><P>Hope i made the problem formulation clear, any input would be greatly appreciated!</P><P> </P><P>//JWP</P>Fri, 13 Dec 2019 20:29:22 GMTJohanWP2019-12-13T20:29:22ZDynamically set number of decimals in a flow
https://powerusers.microsoft.com/t5/General-Power-Automate/Dynamically-set-number-of-decimals-in-a-flow/m-p/426332#M43200
<P>Hello!</P><P> </P><P>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.</P><P> </P><P>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.</P><P> </P><P>Hope i made the problem formulation clear, any input would be greatly appreciated!</P><P> </P><P>//JWP</P>Fri, 13 Dec 2019 20:29:22 GMThttps://powerusers.microsoft.com/t5/General-Power-Automate/Dynamically-set-number-of-decimals-in-a-flow/m-p/426332#M43200JohanWP2019-12-13T20:29:22ZRe: Dynamically set number of decimals in a flow
https://powerusers.microsoft.com/t5/General-Power-Automate/Dynamically-set-number-of-decimals-in-a-flow/m-p/426382#M43201
<P><LI-USER uid="107303"></LI-USER> </P>
<P>I am unaware of any way to accomplish your goal in Power Automate.</P>
<P>You might want to suggest it in the Power Automate Ideas if it isn't already there.</P>
<P> </P>
<P> </P>
<P> </P>Sat, 14 Dec 2019 00:52:44 GMThttps://powerusers.microsoft.com/t5/General-Power-Automate/Dynamically-set-number-of-decimals-in-a-flow/m-p/426382#M43201ScottShearer2019-12-14T00:52:44ZRe: Dynamically set number of decimals in a flow
https://powerusers.microsoft.com/t5/General-Power-Automate/Dynamically-set-number-of-decimals-in-a-flow/m-p/426614#M43202
<P>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</P><P> </P><P>//JWP</P>Sun, 15 Dec 2019 17:11:23 GMThttps://powerusers.microsoft.com/t5/General-Power-Automate/Dynamically-set-number-of-decimals-in-a-flow/m-p/426614#M43202JohanWP2019-12-15T17:11:23ZRe: Dynamically set number of decimals in a flow
https://powerusers.microsoft.com/t5/General-Power-Automate/Dynamically-set-number-of-decimals-in-a-flow/m-p/426867#M43203
<P>Hi <LI-USER uid="107303"></LI-USER> ,</P>
<P> </P>
<P>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!</P>
<P> </P>
<P>Best regards,</P>
<P>Alice </P>
<P>Community Support Team _ Alice Zhang<BR />If this post <STRONG>helps</STRONG>, then please consider <EM><STRONG>Accept it as the solution</STRONG></EM> to help the other members find it more quickly.</P>Mon, 16 Dec 2019 06:16:26 GMThttps://powerusers.microsoft.com/t5/General-Power-Automate/Dynamically-set-number-of-decimals-in-a-flow/m-p/426867#M43203v-alzhan-msft2019-12-16T06:16:26Z