Brian Dunning's FileMaker Custom Functions

mkFormatDollarsWithCommas ( Amount )

Format a number as dollars, separated by commas and truncated to two decimal places. Uses recursion to avoid maximum limit on length of numbers to be formatted.

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

Michael Kupietz   Michael Kupietz - Show more from this author
Michael Kupietz FileMaker Consulting
http://www.kupietz.com

Share on Facebook Share on Twitter

  Sample input:
mkFormatDollarsWithCommas ( 1234567898765432.1 )

mkFormatDollarsWithCommas ( -123 )
  Sample output:
$1,234,567,898,765,432.10


-$123.00

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

This takes any string of digits, with any number of decimal places and an optional negative sign at the beginning, and returns them as a text string formatted dollar sign, commas every three decimal places before the decimal point, and two decimal places after the point.

The advantage of the recursive method used is that there is no maximum limit on the length of the number which is to be converted.

 

Comments

Tim Owen   Tim Owen, Los Angeles, CA
Dec 3, 2009
There appears to be an error in the formula in the line: 'If(Digits<0;"-";"")&"$"&'

If you replace 'Digits' with 'Number' (the correct parameter), it works.

Tim Owen
tim@timowenconsulting.com
 

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: