Brian Dunning's FileMaker Custom Functions

Price_Format ( price )

Formats a number in text with two decimal places.

  Average rating: 4.4 (33 votes) Log in to vote

Brian Dunning   Brian Dunning - Show more from this author
BrianDunning.com
https://www.briandunning.com

Share on Facebook Share on Twitter

  Sample input:
Price_Format ( 3.1 )
  Sample output:
3.10

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This take a number in a number field, no matter how many decimal places, and formats it as text with two decimal places. It does not add a currency symbol. It also does not include commas to separate the thousands places. Just a simple little function for those cases where you need a price properly formatted in a text field.

 

Comments

Tobias   Tobias
Feb 25, 2023
For my use case i added Round(price;2) to the function. If you don't do that, you would get for price=1.999 the result 1.00 instead of 2.00. If you round first it works fine.

Fore example:

Int ( Round(price;2) ) & "." & Right ( "0" & Int ( ( Abs ( Round(price;2) ) - Int ( Abs ( Round(price;2) ) ) ) * 100 + .5 ) ; 2 )

or

Let (
[
pr = Round ( price ; 2 )
];

Int ( pr ) & "." & Right ( "0" & Int ( ( Abs ( pr ) - Int ( Abs ( pr ) ) ) * 100 + .5 ) ; 2 )

)
 
Tobias   Tobias
Feb 25, 2023
For my use case i added Round(price;2) to the function. If you don't do that, you would get for price=1.999 the result 1.00 instead of 2.00. If you round first it works fine.

Fore example:

Int ( Round(price;2) ) & "." & Right ( "0" & Int ( ( Abs ( Round(price;2) ) - Int ( Abs ( Round(price;2) ) ) ) * 100 + .5 ) ; 2 )

or

Let (
[
pr = Round ( price ; 2 )
];

Int ( pr ) & "." & Right ( "0" & Int ( ( Abs ( pr ) - Int ( Abs ( pr ) ) ) * 100 + .5 ) ; 2 )

)
 
Claude Cyr   Claude Cyr, Personnal user
Dec 21, 2023
I am looking for a custom function to replace dots and commas. When I import data, it arrives with a dot and not a comma, which falsifies the values.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: