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

MS Flow expression: How to format calculated SharePoint field to 2 decimal places

we have a calculated column in our SharePoint List with the below formula:

 

=TEXT([Contract Value (£)]/(DATEDIF([Contract Start Date],[Contract End Date],"M")/12),"#,###.00")

here are the settings:

Calculated Field Format 3.PNG

 

In the list, it looks correct:

Calculated Field Format 1.PNG

Now in our Flow, we need to update a field in the list with a concatenated string using the below formula:

 

concat('The Annual Contract Value (£',triggerBody()?['AnnualContractValue'],') falls below the £50,000 annual threshold, so Finance & Procurement Approval was skipped')

this is then used in an email, but the value returned by the concatenated formula is incorrect:

Calculated Field Format 5.PNG

 

what we want to see is £1621.62

 

How can we format that currency number returned by the calculated field to 2 decimal places?

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: MS Flow expression: How to format calculated SharePoint field to 2 decimal places

Hi @livingstonep 

 

Unfortunately there isn't still an easy way to do this in Flow, however I've made a formula to work around this,

I show this here, but the formula to 'cut' this extra numbers is above, when the '2' in red are the amount of decimals to keep, and the ',' are the separator

 

 

substring(triggerBody()?['AnnualContractValue'],0,add(indexof(triggerBody()?['AnnualContractValue'],','),2))

 

addapted to your code the full expression is

 

concat('The Annual Contract Value (£',substring(triggerBody()?['AnnualContractValue'],0,add(indexof(triggerBody()?['AnnualContractValue'],','),2)),') falls below the £50,000 annual threshold, so Finance & Procurement Approval was skipped')

 

If my answer was helpful give me a kudo, if I answered question do not forget to mark as an answer to help the community

 


Did I answer your question? Mark my post as a solution!

Gustavo Moraes, o astronauta brasileiro do Flow!


View solution in original post

4 REPLIES 4
Super User
Super User

Re: MS Flow expression: How to format calculated SharePoint field to 2 decimal places

Hi @livingstonep 

 

Unfortunately there isn't still an easy way to do this in Flow, however I've made a formula to work around this,

I show this here, but the formula to 'cut' this extra numbers is above, when the '2' in red are the amount of decimals to keep, and the ',' are the separator

 

 

substring(triggerBody()?['AnnualContractValue'],0,add(indexof(triggerBody()?['AnnualContractValue'],','),2))

 

addapted to your code the full expression is

 

concat('The Annual Contract Value (£',substring(triggerBody()?['AnnualContractValue'],0,add(indexof(triggerBody()?['AnnualContractValue'],','),2)),') falls below the £50,000 annual threshold, so Finance & Procurement Approval was skipped')

 

If my answer was helpful give me a kudo, if I answered question do not forget to mark as an answer to help the community

 


Did I answer your question? Mark my post as a solution!

Gustavo Moraes, o astronauta brasileiro do Flow!


View solution in original post

livingstonep
Level 8

Re: MS Flow expression: How to format calculated SharePoint field to 2 decimal places

thanks for your answer, but what do you mean by separator?

 

concat('The Annual Contract Value (£',substring(triggerBody()?['AnnualContractValue'],0,add(indexof(triggerBody()?['AnnualContractValue'],','),2)),') falls below the £50,000 annual threshold, so Finance & Procurement Approval was skipped')

surely the sperator in my number is the decimal point ?

 

thanks for your help with this.

Super User
Super User

Re: MS Flow expression: How to format calculated SharePoint field to 2 decimal places

@livingstonep 

Let's assume you obtain details of your list item via a Get Item action Block, so the output value of the column is

body('Get_item')?['YourColumnName']

 

I guess you don't want to modify the existing formula on your Sharepoint List, right? In such a case, I would suggest to use an WDL function based expression:

 

lastIndexOf() returns the starting position or index value for the last occurrence of a substring. This function is not case-sensitive, and indexes start with the number 0. You can use '.' as substring:

lastIndexOf(body('Get_item')?['YourColumnName'],'.')

 

add(): You can use it to calculate the lenght of the substring you need to extract in order to get the number with two decimals.

add(lastIndexOf(body('Get_item')?['YourColumnName'],'.'),1)

 

substring() returns characters from a string, starting from the specified position, or index. Index values start with the number 0. You can use 0 as startIndex, and the length of the substring you need to extract in order to get the number with two decimals.

 

substring(body('Get_item')?['YourColumnName'],0,

add(lastIndexOf(body('Get_item')?['YourColumnName'],'.'),1))

 

Hope this helps





If anybody solved your question, remember to mark its post as a solution!

Proud to be a Flownaut!





Super User
Super User

Re: MS Flow expression: How to format calculated SharePoint field to 2 decimal places

Yes! is your decimal point, because in some cultures is '.' and others ','.

 

The function works?


Did I answer your question? Mark my post as a solution!

Gustavo Moraes, o astronauta brasileiro do Flow!


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!

Top Kudoed Authors
Users Online
Currently online: 55 members 3,401 guests
Please welcome our newest community members: