NumberFormat ( )

Function stats

Average user rating
46
90
9999
Support
FileMaker 7.0 +
Date posted
03 December 2008
Last updated
31 October 2010
Version
Recursive function
No

Author Info
 Agnès

17 functions

Average Rating 4.6

author_avatar



 

Function overview

Prototype

NumberFormat  ( Number;   DecimalPrecision;   ThousandSeparator )


Parameters

Number  Number which you want to format


DecimalPrecision  Number : number of décimal


ThousandSeparator  text : . or space or , or other


Description

Tags:  decimal number precision  

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

Examples

Sample input

NumberFormat ( "1021001,00125" ; 3 ; "." )


Sample output

1.021.001,001

 

Function code

// NumberFormat ( Number ; DecimalPrecision ; ThousandSeparator ) v3.1

/*
to format numbers
*/

//---------------------------------- Exemple
/*
NumberFormat ( "1021001,00125" ; 3 ; "." ) > Result : 1.021.001,001
NumberFormat ( "69584" ; 2 ; " " ) > Result : 69 584,00
*/
//----------------------------------
// @ Agnès -Octobre 2008- BugReport barouh.agnes@wanadoo.fr
//----------------------------------

Let ([
n = Number;
p = DecimalPrecision;
Sep = ThousandSeparator ;
Nbr = Abs ( Round ( n; p ) )
];
Case ( Not IsEmpty ( n ) ;
Case ( GetAsNumber ( n ) < 0; "-" ) &
Substitute ( NumToJText ( Int ( Nbr ); 1; 0 ); ","; Sep ) &
Choose ( p ≤ 0; Filter ( 1/2; ".," ) &
Middle ( Nbr - Int ( Nbr ) & Substitute ( ( 10 ^ p ) - 1; 9; 0 ); 2; p ) )
)
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/90

    Prototype: NumberFormat( Number; DecimalPrecision; ThousandSeparator )
    Function Author: Agnès (http://www.fmfunctions.com/mid/46)
    Last updated: 31 October 2010
    Version: 3.1

*/
// ===================================

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (32)
Date  (28)
XML  (27)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (13)
Filter  (12)
Layout Objects  (11)
Design  (10)
Array  (8)