Price_Format ( price )
Formats a number in text with two decimal places.
Average rating: 4.4 (33 votes) Log in to vote
Brian Dunning - Show more from this author
BrianDunning.com https://www.briandunning.com |
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 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 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, 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. | ||
Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.