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.

Dual Super User
Dual 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



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/

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

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

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

thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (5,557)