Software Venture Consulting
ToMarket

FileMaker Pro downloads & Resources
FileMaker Custom Functions
FileMaker Web Viewer Examples
FileMaker Pro & Lasso Consulting
Training
FileMaker Books
FileMaker Articles
FileMaker Error Reference

Free Web Tools
Free FileMaker Tools

Personal Pages
Videos
Adventures
Links

Shopping Cart
Shopping Cart

Search:

Free Newsletter
Signup


Contact


Privacy Policy



FileMaker is a registered trademark of FileMaker, Inc. in the U.S. and other countries.

 

 

 FileMaker Pro Custom Functions

List  |  Show Random  |  Upload  |  Add This to Your Site

FormatNumber ( number, format )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 4.1  (8 votes)
  Discuss this Custom Function

Lewis C. Lorenz, Lorenz Companies
www.LorenzCom.com/software

Returns text string of number in the requested format. Function allows complete FileMaker Pro number formatting using an intuitive free-form format structure.

Sample Input:
FormatNumber ( 14725.3675, “$,.2 US” )
FormatNumber ( -14725.3675, “$(,.2) US\r0\” )
FormatNumber ( -14725.3675, “#,.\c255\” )
FormatNumber ( 1, “Yes||No” )
FormatNumber ( 5973600, "^" )
FormatNumber ( 59703600, "~0 kg" )
Sample Output:
$14,725.37 US
$(14,725.36) US [rounding off]
#-14,725.3675 [text color is red]
Yes
5.9736e6
59.7036e6 kg


 Then copy & paste into FileMaker Advanced's Edit Custom Function window.

Click here to copy To Clip Manager if you have myFMbutler's Clip Manager installed

Description:

FormatNumber ( number, format )

Returns a text string of the number in the requested format.

By Lewis C. Lorenz
Last updated: 2/11/2014

Function allows complete FileMaker Pro number formatting using an intuitive, liberal format structure. Free-form formatting provides the user flexible control over what is included in the final formatted result. Escaped options can be used instead. Include the following elements in the format string in the order the user desires to produce a formatted number.

HELP:
Passing '?' as the only content of 'format' returns a shortened version of this text.

NUMBER FORMATTING:
, - (thousands separator) integer portion of the number is "thousands separated".
. - (decimal separator) displays of the decimal portion of the number.
# - (number) specifies the rounding precision (controls the count of decimal number digits to display):
0 - number decimal and decimal separator is not displayed. Enables positioning of negative signs and notations.
1...n - Truncation and rounding precision of the number decimal.
. - decimal separator only, with no number, displays the unaltered number decimal.
^ - (caret) formats number in scientific E notation.
~ - (tilde) formats number in engineering E notation.

NEGATIVE SIGN FORMATTING:
- - minus sign (default) (default: left).
<> - angle brackets (default: left and rigth).
() - parentheses (default: left and right).
CR - credit symbol (default: right).
∆ - delta symbol (default: left). (Black delta is output.)
Minus sign, credit and delta symbols can be displayed on the left or right of the formatted number by placing them to the left or right of an included decimal separator, or zero, in 'format'. Negative signs are placed at their default location when no decimal separator is included.

BOOLEAN FORMATTING:
|| - two pipe characters divide boolean results. True number returns left side. False number returns right side.

NOTATION FORMATTING:
% - percent sign. Inclusion in 'format' forces multiplication of the number by 100 (default: right).
$, £, #, etc. - dollar, pound, hash, and any other characters, can be included in the formatted number (default: left).
Percent, currency and other notations can be placed on either side of the formatted number depending on whether you place them at the left or right of an included decimal separator, or zero, in 'format'. Notations are placed at their default position when no decimal separator is included. The user must insure that the notations in 'format' produces the desired formatted result.

ESCAPED OPTIONS FORMATTING:
\T - (text) thousands separator (default: system).
\D - (text) decimal separator (default: system).
\R - (boolean) round number to passed precision (default: true).
\Z - (boolean) show number if zero (default: true).
\F - (boolean) fill (pad) decimal with zeros to length of passed precision (default: true).
\SL - (text) negative sign (-, <>, (), CR, ∆) appearing on left side of number (default: minus sign).
\SR - (text) negative sign (-, <>, (), CR, ∆) appearing on right side of number (default: empty).
\PL - (boolean) proximity of negative sign on left side is next to number (default: true).
\PR - (boolean) proximity of negative sign on right side is next to number (default: true).
\NL - (text) notation sign ($, %, #, etc.) to appear on left side of number (default: empty).
\NR - (text) notation sign ($, %, #, etc.) to appear on right side of number (default: empty).
\C - (integers) comma-separated RGB number text (#,#,#) to color negative number (default: black).
\X - (integer) exponentiation formatting: 0 = none, 1 = scientific, 2 = engineering (default: 0).
\BP - (text) positive response to boolean formatting.
\BN - (text) negative response to boolean formatting.
Escaped options override free-form format, defaults and add formatting. Enclose each option with escape (backslash) characters \\\\.

EXAMPLES:
FormatNumber ( 14725.3675, "$,.2 US" ) = $14,725.37 US
FormatNumber ( -14725.3675, "$(,.2) US\r0\" ) = $(14,725.36) US [rounding off]
FormatNumber ( -14725.3675, "#,.\c255\" ) = #-14,725.3675 [text color is red]
FormatNumber ( 1, "Yes||No" ) = Yes
FormatNumber ( 5973600, "^" ) = 5.9736e6
FormatNumber ( 59703600, "~0 kg" ) = 59.7036e6 kg

REVISION NOTES:
Revised February 11, 2014. Added code to process numbers input in scientific notation format and to return numbers in scientific and engineering notation format. Reformatted the boolean separator to be two pipe characters and added escape options to allow setting Boolean positive and negative values. Optimized the code to remove redundancies, decrease the overall size, and speed up processing. Restructured the help text to make it more concise so that it can be used easier in tool tip popups. Also, added code to determine system decimal and thousands separators.

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

This is my Custom Function and I want to edit it

Discuss:

There are no comments yet. Be the first to post a comment about this Custom Function! Please try to keep it brief & to the point. Anyone can post:

Your Name:
City/Location:
Comment:
characters left. If you paste in more than 1500 characters, it will be truncated. Discuss the function - advertisements and other useless posts will be deleted.
Answer 5 + 8 =
Search for Custom Functions:

Custom Functions Widget
Download the Custom Function Dashboard Widget for OS X
Keep all the latest Custom Functions right at your fingertips!

Newest Custom Functions:

1. CF.TurnIt ( ValueToTurn )
  (Wed, Jul 30, 12:32pm)
2. Patternize ( direction ; pattern ; replaceChar ; value ; pad? )
  (Fri, Jul 25, 5:48pm)
3. RequestSQL ( fieldDesired ; fieldKey ; valueKey ; valueType)
  (Fri, Jul 25, 7:31am)
4. isLeapYear ( _year )
  (Thu, Jul 17, 8:29am)
5. AgeCalculation( Date( 4 ; 12 ; 1980 ) ;
  (Thu, Jul 17, 8:10am)
6. ntBitwiseOperation ( ope ; base ; value1 ; value2 )
  (Wed, Jul 16, 11:22pm)
7. ntRepeat( times ; statements ; resultValueName )
  (Mon, Jul 07, 8:51pm)
8. ฺBookRentalCal ( BookingStart; 1.5)
  (Sat, Jul 05, 8:25pm)

RSS Feed of Custom Functions