# NumberFormat ( Number ; DecimalPrecision ; ThousandSeparator )

to format numbers with decimal and thousand separator (option)

Average rating: 4.3 (86 votes) Log in to vote

Agnes Barouh - Show more from this author
Tic Tac http://www.tictac.fr/CoinFileMaker/Page.html |

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

** Nov 2014

If you want thousand separator for décimal, the last line change :

Substitute ( NumToJText ( Middle ( Nbr - Int ( Nbr ) & Substitute ( ( 10 ^ p ) - 1; 9; 0 ) ; 2 ; p ) ; 1; 0 ); ","; Sep )

instead of

Middle ( Nbr - Int ( Nbr ) & Substitute ( ( 10 ^ p ) - 1; 9; 0 ); 2; p ) )

** April 9/10 : calculation modified if n is empty return nothing

** December, 21. : calculation modified : change Filter ( 1,1 ; ".;" ) by Filter ( 1/2 ; ".;" ) for all language ( x,xx for French, x.xx English and all - [comma or point in number]) ) **

** December, 18. : calculation modified : add GetAsNumber() for get signe

for entry without 0 -> ,123 or 0,123 **

NumberFormat ( Number ; DecimalPrecision ; ThousandSeparator ) v1.0

is not recursive

to format numbers with decimal and thousand séparator (option)

//---------------------------------- Example

NumberFormat ( "1021001,00125" ; 3 ; "." ) > Result : 1.021.001,001

NumberFormat ( "69584" ; 2 ; " " ) > Result : 69 584,00

## Comments

David Jan 19, 2010 |
||

This is a great function. How would you go about editing it so that one can show the decimals only if there are decimals? Much like the number formatting for a number field on a layout. Great work! |
||

Agnès, Paris Apr 9, 2010 |
||

Hello and Thank You ! "How would you go about editing it so that one can show the decimals only if there are decimals?" It can do without adding a parameter to the function, perhaps simply with the following calculation, with this, each chose its resul ? If ( int ( MyNum ) <> (MyNum) ; NumbertFormat ( MyNum ; 2 ; "" ) ; MyNum ) I do not know... Agnès |
||

Tiago, Antwerp Aug 17, 2011 |
||

Nice man, Just what I needed :) loved it |
||

plop, paris Apr 25, 2012 |
||

thank you | ||

kolvorok, Bergen, Norway Oct 25, 2013 |
||

This was great! Thanks, France...:-) | ||

Andy Smith Feb 11, 2015 |
||

Thank you, very useful. For myself I needed it to use the existing precision of the number (when I pass "" as the precision param). I think that is what David (first comment) also required. Just add this line below p = DecimalPrecision ; p = If ( IsEmpty ( p ) and n ≠ Int ( n ) ; Length ( Abs ( n ) - Int ( n ) ) - If ( n < 0 ; 2 ; 1 ) ; p ) ; |
||

Emeric, Bordeaux May 25, 2016 |
||

Un immense bravo et un grand merci ! | ||

Peter Wagemans, Lesterius Mar 23, 2018 |
||

Almost 10 years later, this function still rocks. | ||

Agnès, Paris Mar 23, 2018 |
||

SHE did not get older ;) glad she's still useful ! |
||

Fabrice Ricker, Kultur und Computer Jul 26, 2019 |
||

Coucou, je me suis permis d'extrapoler un peu au fil des besoins. Avec un "rendez à César ce qui est à César" en début de commentaire. https://www.briandunning.com/cf/2283 Et merci encore, I still love this "trics". |
||

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