- Microsoft Power Automate Community
- Community News
- News & Announcements
- Get Help with Power Automate
- General Power Automate Discussion
- Connecting To Data
- Building Flows
- Using Flows
- AI Builder
- Power Automate Mobile App
- Translation Quality Feedback
- Share, Chat, Discuss
- Community Chat & Announcements
- Power Automate Cookbook
- Off Topic Discussion
- Power Platform Integration - Better Together!
- Power Platform Integrations
- Power Platform and Dynamics 365 Integrations
- Watch & Share Videos
- Webinars and Video Gallery
- MBAS Gallery 2019
- MBAS Gallery 2020
- Give Feedback & Share Ideas
- Power Automate Ideas
- Report Issues
- I Found A Bug
- Find & Join Local User Groups
- Power Automate User Groups
- Read & Share Blogs
- Power Automate Community Blog
- Community Blog Topic Suggestions
- Community Support
- Community Accounts & Registration
- Using the Community
- Community Feedback

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Microsoft Power Automate Community
- Forums
- Get Help with Power Automate
- Building Flows
- Re: Format decimal numbers

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

Highlighted

Damo_R

Frequent Visitor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-21-2017
03:15 PM

I am trying to format the data of a calculated field within the flow to send in an email to show 2 decimal places. has anyone acheived this?

I have tried both Text and Round and several iterations of these functions and they come back as invalid templates.

Can anyone shine any light on this?

the value from the column is 1.50000000000 i only want to see 1.5

Solved! Go to Solution.

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

** Each time you click on any of our inspiring answers 'Thumb up' icon...**

**...an ewok scapes from the stormtroopers. **

Be grateful, Thumbs up! Save the Galaxy for free!

Escribo sobre Power Automate en:

https://medium.com/anyone-can-automate/

efialttes

Dual Super User

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-22-2017
03:25 AM

As far as I know, math functions currently supported in Microsoft FLow as "expressions" are the ones defined here:

https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language

I guess you can multiply by 100, convert into integer, get back to float and divide into 100; but I haven't tested myself; so unsure if both float() and int() accepts non-string parameters

Hope this helps

Be grateful, Thumbs up! Save the Galaxy for free!

Escribo sobre Power Automate en:

https://medium.com/anyone-can-automate/

Proud to be a Flownaut!

19 REPLIES 19

Highlighted

** Each time you click on any of our inspiring answers 'Thumb up' icon...**

**...an ewok scapes from the stormtroopers. **

Be grateful, Thumbs up! Save the Galaxy for free!

Escribo sobre Power Automate en:

https://medium.com/anyone-can-automate/

efialttes

Dual Super User

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-22-2017
03:25 AM

As far as I know, math functions currently supported in Microsoft FLow as "expressions" are the ones defined here:

https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language

I guess you can multiply by 100, convert into integer, get back to float and divide into 100; but I haven't tested myself; so unsure if both float() and int() accepts non-string parameters

Hope this helps

Be grateful, Thumbs up! Save the Galaxy for free!

Escribo sobre Power Automate en:

https://medium.com/anyone-can-automate/

Proud to be a Flownaut!

Highlighted
##

Damo_R

Frequent Visitor

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-22-2017
07:52 AM

@efialttes thank you so much for your repsponse and the link you provided. With a little reading and some trial and error i have come up with the following:

**if(or(greater(body(**'Create_item'**)**?['Days_x0020_Total'],** string** **(**10**))**,**equals(body(**'Create_item'**)**?['Days_x0020_Total'],**string(**10**)))**,**take(body(**'Create_item'**)**?['Days_x0020_Total'],4**)**,**take(body(**'Create_item'**)**?['Days_x0020_Total'],3**))**

This basically looks at the value in the total days field and determines if it is greater or equal to 10, if yes then it will produce 4 place and if no it will produce 3 places.

works a treat

Highlighted
##

** Each time you click on any of our inspiring answers 'Thumb up' icon...**

**...an ewok scapes from the stormtroopers. **

Be grateful, Thumbs up! Save the Galaxy for free!

Escribo sobre Power Automate en:

https://medium.com/anyone-can-automate/

efialttes

Dual Super User

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-22-2017
10:02 AM

You are welcome. Thanks for sharing!

Be grateful, Thumbs up! Save the Galaxy for free!

Escribo sobre Power Automate en:

https://medium.com/anyone-can-automate/

Proud to be a Flownaut!

Highlighted
##

StevenWade

Advocate II

Rounding for specific scenarios

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-21-2018
08:24 AM

There's still no generalized rounding solution in Flow, which means building solutions specific to your data. Here's an approach I took when I needed to round from three decimals (#.###) to two (#.##) for display purposes. Fortunately, I knew I'd always be getting data in a #.### format, but you could pretty easily extend this to find the decimal place if the number of places to the left of the decimal was unknown.

if(contains('56789', substring(string(triggerBody()['number']),4,1)),substring(string(add(triggerBody()['number'],0.01)),0,4),substring(string(triggerBody()['number']),0,4))

Highlighted
##

henrim

Regular Visitor

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

10-18-2018
03:32 AM

I just used your suggestion to round the result of my division formula:

Original expression:

**div(variables('Sum'),5)**

Which returned the full result, i.e 1.6666666 or similar.

I formatted it to 1 decimal using this expression:

**div(float(int(mul(div(variables('Sum'),5),10))),10)**

that is

- take result from division
- multiple by 10
- converting to int
- converting to float (else it became an integer result)
- dividing by 10

Thanks for the hint!

Highlighted
##

jan-dolejsi

New Member

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

11-05-2018
07:40 AM

It was not as simple, because int() and float() only accept string arguments. So you get a run-time error like this:

On top of that, the int() function only accepts string representations of integer numbers - it does not accept any floating point number. So I had to turn the number to string, select the part before the '.' and pass it to int(). Not sure if the '.' is subject to localization, which would obviously fail.

This is the expression I've put into a Compose action:

div(int(first(split(string(mul(123.456, 10.0)),'.'))), 10.0)The output was

123.4

Highlighted
##

aCTim

New Member

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-10-2019
08:17 AM

Thanks to Damo_R I was able to round numbers for our case, with two numbers behind. A little bit ugly, but it works.

Initializing 2 variables.

variable var as string

first(split(string(mul(123.454, 1000.0)),'.'))

(you can put your number or varible where 123.454 is)

variable varTemp as Integer

int(variables('var'))

than we go on with a condition

if

int(last(variables('var')))

equal or even to 5

set var to

sub(add(int(variables('varTemp')),10),int(last(string(variables('varTemp')))))

else

set var to

sub(int(variables('varTemp')),int(last(string(variables('varTemp')))))

finally transform it to a float (int would slice the numer)

div(float(int(div(int(variables('var')),10))),100)

Highlighted
##

Damo_R

Frequent Visitor

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

04-10-2019
10:32 AM

Glad my efforts could help you

Highlighted
##

degvalentine

Advocate V

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-18-2019
05:48 PM

Here's a similar solution, but no temp variables are needed.

Uses variables('myFloat') to represent the number you want to round.

div(

add(

mul(variables('myFloat'), 1000),

sub(

if(

greaterOrEquals(

mod(mul(variables('myFloat'), 1000), 10),

5

),

10,

0

),

mod(mul(variables('myFloat'), 1000), 10)

)

),

1000

)

Or, all in one line:

div(add(mul(variables('myFloat'),1000),sub(if(greaterOrEquals(mod(mul(variables('myFloat'),1000),10),5),10,0),mod(mul(variables('myFloat'),1000),10))),1000)

The float is multilpiled by 1000 before doing modulo to avoid tiny-fraction math errors (e.g. returning 0.00499999... instead of 0.005).

Using add, sub, mul, div, and mod to round a float... a reasonable workaround... XD

If you're looking for an expression to format for currency with a thousands separator, see my expression in another post.

Highlighted
##

nsauter23

Frequent Visitor

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

09-20-2019
10:36 AM

This can be done with the following

substring(string(triggerOutputs()?['body/tileValue'])),0,3)

Don't forget the decimal '.' counts as a character because this is a string not an actual intager. It is not actual rounding, but it accomplished what I needed for my email to look cleaner.

Highlighted
##

dmistry

Post Prodigy

Re: Rounding for specific scenarios

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-11-2020
05:55 PM

@StevenWade , thanks so much for sharing this. I want to limit my decimals to two points, can you please help me with what modification should I make in the expression you shared please, thanks in advance.

Highlighted
##

dmistry

Post Prodigy

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-11-2020
06:21 PM

@jan-dolejsi thanks for sharing. I have a requirement to limit decimal points to two, so as an example: 40.325 should result into 40.33. Can you please help me with the revised formula, thanks in advance.

Highlighted
##

dmistry

Post Prodigy

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-11-2020
06:33 PM

@degvalentine thanks for sharing, I used your expression for limiting decimals to two places and it seems to work well. Noticing a small issue, if the values are 2.2, 4.3 etc then the expression returns 2.2, 4.3 only but instead i want it to show 2.20, 4.30, is it possible? Please help.

Highlighted
##

degvalentine

Advocate V

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-11-2020
10:35 PM

Hi @dmistry,

Actually, my hideous workaround is no longer needed. They added the "formatNumber" function. Please use that instead. Here's the syntax for common currency formatting (without currency symbol):

`formatNumber(variables('myFloat), 'N', 'en-US')`

Highlighted
##

dmistry

Post Prodigy

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-12-2020
04:07 AM

Thanks a lot for. My field is of type number. Can u give some info on the parameter ‘N’ specified in the expression, would it help limiting decimals to two points? Thanks.

Highlighted
##

degvalentine

Advocate V

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-12-2020
08:55 AM

Here's the doc for all available number formatting options: https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings

Highlighted
##

dmistry

Post Prodigy

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

02-12-2020
09:03 AM

Thanks @degvalentine a lot for sharing this, I was stuck with this issue since 3 days and this helped me out, keep up the good work, cheers!!

p.s: it works great and gives me two decimal points.

Highlighted
##

rafaelbenicio

Helper II

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-25-2020
09:40 AM

degvalentine

Advocate V

Re: Format decimal numbers

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

05-26-2020
09:46 AM

@rafaelbenicio you should use the "formatNumber()" expression or the "Format Number" action.

Here are links to the standard formats and custom formats.

`formatNumber(1.995,'N2') // returns "2.00"`

Announcements

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

Top Solution Authors

User | Count |
---|---|

22 | |

19 | |

19 | |

16 | |

16 |