cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
livingstonep
Kudo Commander
Kudo Commander

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
gamoraes
Memorable Member
Memorable Member

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
gamoraes
Memorable Member
Memorable Member

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

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.

efialttes
Super User
Super User

@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!



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
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (2,405)