Software Venture Consulting

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

insert_commas ( number )

Rate this function:  

RatingRatingRatingRatingRating
  Average rating: 4.2  (28 votes)
  Discuss this Custom Function

Matthew Stetson, Antidote Solutions
http://www.antidotesolutions.com

Insert commas in a number

Sample Input:
Insert_Commas ( 1000000 )
Sample Output:
1,000,000


 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:

Inserts commas before every third digit before a decimal point. Uses recursion to handle any number, including negative values and decimals.

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:

5 most recent comments | Show all 8 comments

this work around resolved issue

Case(
Int( number ) <> number;
Insert_Commas( Int( number ) ) & GetAsText( Abs( number ) - Abs( Int( number ) ) );
Length( number ) > 3;
Insert_Commas( Left( number; Length( Substitute ( number ; "," ;"" ) ) - 3 ) ) & "," & Right( Substitute ( number ; "," ;"" ); 3 );
number
)

thom droz, Fort Lauderdale
November 30, 2010 10:17am

Just uploaded my function formatN, which does the more or less the same as yours, and works more or less in the same way, but is easier to read.
Forms the kernel of my other function formatAmount.

formatN( naturalNumber, separator ) =

Let([
N = GetAsText( naturalNumber ) ;
l = Length( N )
];
Case(
l > 3
; FormatN( Left( N ; l - 3 )) & separator & Right( N ; 3 )
; N
)
)

Martin Spanjaard, Amsterdam, the Netherlands
May 26, 2011 6:01am

what if i wanted to use numbers in this format

10,00,00,000


?????

pls show some way..using fmp12 adv

indiguy, india
January 11, 2014 1:41pm

Most of these functions screw up if the input is text and contains either a user-entered comma or ".00" at the end (in the case you're passing a dollar amount). This one is more thorough and should work with any format of a number:


f_commas ( number )

Let ( [
nums = "0123456789" ;
p = Position ( number ; "." ; 1 ; 1 ) ;
p = If ( p <= 0 ; Length ( number ) + 1 ; p ) ;
p2 = Position ( number ; "," ; 1 ; 1 ) ;
p = If ( p2 > 0 ; p2 ; p ) ;

n1 = Middle ( number ; p - 1 ; 1 ) ;
n2 = Middle ( number ; p - 2 ; 1 ) ;
n3 = Middle ( number ; p - 3 ; 1 ) ;
n4 = Middle ( number ; p - 4 ; 1 )
] ;

If (
p > 4 and Exact ( Filter ( n1 ; nums ) ; n1 ) and Exact ( Filter ( n2 ; nums ) ; n2 ) and Exact ( Filter ( n3 ; nums ) ; n3 ) and Exact ( Filter ( n4 ; nums ) ; n4 ) ;
f_commas ( Left ( number ; p - 4 ) & "," & Middle ( number ; p - 3 ; 99999999 ) ) ;
number
)
)

Chris Bishop, Los Angeles
March 14, 2017 12:31pm

More concise version (plus can choose 2, 3, 4 digits per comma):

f_commas ( number ; spacing )


Let ( [
nums = "0123456789" ;
p = Position ( number ; "." ; 1 ; 1 ) ;
p = If ( p <= 0 ; Length ( number ) + 1 ; p ) ;
p2 = Position ( number ; "," ; 1 ; 1 ) ;
p = If ( p2 > 0 ; p2 ; p ) ;

n = Middle ( number ; p - (spacing + 1) ; (spacing + 1) )
] ;

If (
p > (spacing + 1) and Exact ( Filter ( n ; nums ) ; n ) ;
f_commas ( Left ( number ; p - (spacing + 1) ) & "," & Middle ( number ; p - (spacing) ; 99999999 ) ; spacing ) ;
number
)
)

Chris Bishop, Los Angeles
March 14, 2017 1:24pm

Make 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 3 + 7 =
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. decFromHex ( hexValue )
  (Mon, Oct 16, 12:34pm)
2. MonthYearList ( startmonth ; startyear ; numbermonth ; short )
  (Mon, Oct 16, 3:38am)
3. ErrorDescription ( errorNumber )
  (Wed, Sep 27, 2:51am)
4. decodeEntities (text)
  (Wed, Sep 27, 1:22am)
5. HexidecimalToNumber ( HexidecimalValue ; counter )
  (Mon, Sep 25, 12:39pm)
6. FixedFieldConverter ( Fieldname ; f1 ; f2 ; f3 ; f4 ; f5 ; f6 ; f7 ; f8 ; f9 ; f10 ; f11 ; f12 ; f13 ; f14 ; f15 ; f16 ; f17 ; f18 ; f1
  (Fri, Sep 15, 12:34pm)
7. ShannonEntropy ( text )
  (Thu, Sep 07, 5:59am)
8. LetterCount ( text ; summary )
  (Thu, Sep 07, 5:53am)

RSS Feed of Custom Functions