cancel
Showing results for 
Search instead for 
Did you mean: 

Currency and decimal format in Microsoft Flows

I am building an email output where I am retreiving currency, ie formatted as currency in SharePoint.  It would be good to be able to format the "float" to 2 decimal places using workflow definition language.  I have been able to use substring but it fails when the number from the SharePoint list is 0.  It appears that 0 is actually represented as 0.0 and not presenting a second decimal place as integer numbers do.

Status: Under Review

Thanks for the input, we will evaluate this for a future release.

Comments
Level: Powered On

Sure hope they figure this one out.  Hoping for a workaround until then.  Please post if you figure it out.

Anonymous
Not applicable

I followed the post link above and it helped with my solution - it does still snag with a single decimal place - but where that is possible in the fields I work with I just pad the answer with an addtional "0"

For fields where I know i will get > 1 decimal place the formula is:

if(equals(float(triggerBody()['Data_x0020_Field']),0), 0,substring(string(triggerBody()['Data_x0020_Field']),0,if(equals(float(triggerBody()?['Data_x0020_Field']),0),0, add(indexof(triggerBody()['Data_x0020_Field'],'.'),3))))

 

where the field has a possibility of being 1 decimal place the answer is rounded to the nearest 0.0 and I add a 0 to the text field:

if(equals(float(triggerBody()['Data_x0020_Field']),0), 0,substring(string(triggerBody()['Data_x0020_Field']),0,if(equals(float(triggerBody()?['Data_x0020_Field']),0),0, add(indexof(triggerBody()['Data_x0020_Field'],'.'),2))))

 

and the filed looks like:

the value is "Outputs('Compose')0"

 

The downside is the accuracy to reduced - single decimal place and if the figure is zero it appears as "00"

 

For my purposes it suits.

Level: Power Up

Hi sabirin, I am in the same situation...hope to have an easy solution

Anonymous
Not applicable

Did anyone get a solution? 

Level: Powered On

I lost a lot of time searching for a solution to add two currency values ​​together and then CORRECTLY round the result to 2 digits after the comma in my Flow... the basic function 'Round' exists everywhere, except in standard flow math functions.

I ended up by writing this:

div(float(add(int(first(split(string(mul(variables('FloatStartValue'),100)),'.'))),if(greater(int(substring(last(split(string(mul(variables('FloatStartValue'),100)),'.')),0,1)),5),1,0))),100)

 

This "function" converts a float value (=FloatStartValue) into an new float value, rounded to 2 decimal digits...
I should prefer something like round(variables('FloatStartValue'),2) in the future...

Level: Powered On

error: should be:

div(float(add(int(first(split(string(mul(variables('FloatStartValue'),100)),'.'))),if(greater(int(substring(last(split(string(mul(variables('FloatStartValue'),100)),'.')),0,1)),4),1,0))),100)

Power Automate Staff
Status changed to: Under Review

Thank you for this suggestion.

Power Automate Staff
Status changed to: Under Review

Thanks for the input, we will evaluate this for a future release.

Level: Powered On
Please make this feature happen. - formatting / configurable the visualizing thousand-delimiter to point / comma - please integrate a "round" function, for example to round a float to 2 decimal places! It looks really bad when showing the float values calculated in the flow in an email, because there are a lot of decimal places shown. And also not option for configure thousand-delimiter.
Level: Powered On
In Addition: For me a "round" function should be a available by default. I badly miss a round-function at all. But a global config to set the decimal places of float would also be good, so we not have to round every single number which we want to show for example in an email.