cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dmistry
Level 8

How to default Flow Selection to output number field to two decimal places

Hi,

 

In a SPO list, I have a number field that logs total expenses and I have limited it to two decimal places from the list settings. 

556.JPG

Inside my flow, I am simply fetching these field values by using get items->select-create html table->compose and then using send an email action with html enabled, I am sending it for approval,  see sample below

896.JPG

Now as shown above, I want to make sure that 146.4 is represented as 146.40, is this something possible to do? See flow screenshot below. 

7745.JPG

Thanks in advance. 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: How to default Flow Selection to output number field to two decimal places

@dmistry 

I've seen this question before and there really is no clean way to accomplish this.  That said,  I was able to construct an expression that can be used for this purpose.  It is, without a doubt, the ugliest expression that I have ever composed.  In addition, there is no telling how much this will slow down your Flow.   In short, I did this mainly to see if I could - it works but I'm not sure it is a good idea to use this in a production Flow.

One caveat is that I am not doing rounding - I am just taking the 2 characters to the right of the decimal point if there are more than 2.

I tested the following expression in a variety of situations with input from a SharePoint column formatted as per your example.

Here is my expression:

 

if(equals(mod(variables('varNumber'),1),0),concat(variables('varNumber'),'.00'),concat(first(split(string(variables('varNumber')),'.')),'.',substring(concat(last(split(string(variables('varNumber')),'.')),'0'),0,2)))

 

if(equals(mod(variables('varNumber'),1),0),concat(variables('varNumber'),'.00'),concat(first(split(string(variables('varNumber')),'.')),'.',substring(concat(last(split(string(variables('varNumber')),'.')),'0'),0,2)))
 
 
 
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

4 REPLIES 4
Super User
Super User

Re: How to default Flow Selection to output number field to two decimal places

@dmistry 

I've seen this question before and there really is no clean way to accomplish this.  That said,  I was able to construct an expression that can be used for this purpose.  It is, without a doubt, the ugliest expression that I have ever composed.  In addition, there is no telling how much this will slow down your Flow.   In short, I did this mainly to see if I could - it works but I'm not sure it is a good idea to use this in a production Flow.

One caveat is that I am not doing rounding - I am just taking the 2 characters to the right of the decimal point if there are more than 2.

I tested the following expression in a variety of situations with input from a SharePoint column formatted as per your example.

Here is my expression:

 

if(equals(mod(variables('varNumber'),1),0),concat(variables('varNumber'),'.00'),concat(first(split(string(variables('varNumber')),'.')),'.',substring(concat(last(split(string(variables('varNumber')),'.')),'0'),0,2)))

 

if(equals(mod(variables('varNumber'),1),0),concat(variables('varNumber'),'.00'),concat(first(split(string(variables('varNumber')),'.')),'.',substring(concat(last(split(string(variables('varNumber')),'.')),'0'),0,2)))
 
 
 
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

dmistry
Level 8

Re: How to default Flow Selection to output number field to two decimal places

Thanks a lot for your answer @ScottShearer  , as always, appreciate it.

Yes I was reading in some forums and could not find a better way to resolve this. I will try this and see if it works well. Although my flow is very complex and so won't be ideal if this expression would slow it down. Additonally I have about 5 more fields for which I would have to go for the expression appraoch so believe shouldn't go for it as far as prod flow is concerned, thoughts?

Highlighted
Super User
Super User

Re: How to default Flow Selection to output number field to two decimal places

@dmistry 

I suggest giving it a try and see if slows down the Flow as much as I think that it might (I've been wrong before...).  Try it with just one column first.

Please let me know how it goes.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
dmistry
Level 8

Re: How to default Flow Selection to output number field to two decimal places

Thanks for the valuable comments @ScottShearer , it works well and I don't see any lag at all for the flow run.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Users Online
Currently online: 358 members 5,143 guests
Please welcome our newest community members: