About this article
FormatNumber() is a function that formats numbers.
Currently (September 2021) only a data source that contains a column of Type Number
is supported.
In a template a dropdown form field needs to be linked to this Number
column, using a combo box is not supported.
It's also possible to use a HostSystem field (for example if you want to get data from an external system such as Salesforce) or a number of an External Data Source.
Sections in this article:
Prerequisites
|
Syntax
Syntax | {{FormatNumber(Number,Format,Language)}} |
Input | number, text, text |
Output | Number formatted according to format and language |
|
In the binding examples below the form field 'Amount' is used. This is a dropdown field that is linked to the column 'Price' of the 'Products' data source:
Standard numeric format strings
Currency (C or c)
In the examples below the DocumentLanguage in the user profile is set to 'en-US'.
Binding | Input | Output |
{{FormatNumber(Form.Amount.Price, "C", "da-DK")}} | 1234 | 1.234,00 kr. |
{{FormatNumber(Form.Amount.Price, "C", "nl-NL")}} | 1234 | € 1.234,00 |
{{FormatNumber(Form.Amount.Price, "C", "nl-NL")}} | -1234 | € -1.234,00 |
{{FormatNumber(HostSystem.Amount, "C", "nl-NL")}} | 1234 | € 1.234,00 |
{{FormatNumber(Form.Amount.Price, "C", DocumentLanguage)}} | 1234 | $1,234.00 |
{{FormatNumber(Form.Amount.Price, "C")}} | 1234 |
$1,234.00 |
|
Exponential (E or e)
For exponential notation the default value of the precision specifier (number of decimal digits) is 6.
You can add a number behind the E (e.g. '2') to change the value of the precision specifier.
Binding | Input | Output |
{{FormatNumber(Form.Amount.Price, "E", "en-US")}} | 1234 | 1.234000E+003 |
{{FormatNumber(Form.Amount.Price, "E2", "en-US")}} | 1234 | 1.23E+003 |
Fixed-Point (F or f)
Fixed-Point returns integral and decimal digits with optional negative sign.
You can add a number behind the E (e.g. '1') to change the value of the precision specifier.
Binding | Input | Output |
{{FormatNumber(Form.Amount.Price, "F", "en-US")}} | 1234 | 1234.000 |
{{FormatNumber(Form.Amount.Price, "F1", "en-US")}} | 1234 | 1234.0 |
General (G or g)
General returns the more compact of either fixed-point or scientific notation.
You can add a number behind the G (e.g. '4') to change the value of the precision specifier.
Binding | Input | Output |
{{FormatNumber(Form.Amount.Price, "G", "en-US")}} | 1234 | 1234 |
{{FormatNumber(Form.Amount.Price, "G4", "en-US")}} | 1234 | 1234 |
{{FormatNumber(HostSystem.Amount, "G", "nl-NL")}} | 123.456 | 123,456 |
{{FormatNumber(HostSystem.Amount, "G4", "en-US")}} | 123.4546 | 123.5 |
|
Number (N or n)
Number returns integral and decimal digits, group separators, and a decimal separator with optional negative sign.
You can add a number behind the N (e.g. '1' or '3') to change the value of the precision specifier.
Binding | Input | Output |
{{FormatNumber(Form.Amount.Price, "N", "en-US")}} | 1234 | 1,234.000 |
{{FormatNumber(Form.Amount.Price, "N1", "en-US")}} | 1234 | 1,234.0 |
{{FormatNumber(HostSystem.Amount, "N", "en-US")}} | 1234.567 | 1,234.57 |
{{FormatNumber(HostSystem.Amount, "N3", "en-US")}} | -1234.56 | -1,234.560 |
|
Percentage (P or p)
Percentage returns a number multiplied by 100 and displayed with a percent symbol.
Note: in these examples 'Form.Amount.Price' is replaced by 'Form.Percentage.Value', and 'HostSystem.Amount' by 'HostSystem.Percentage'.
Binding | Input | Output |
{{FormatNumber(Form.Percentage.Value, "P", "en-US")}} | 1 | 100.00 % |
{{FormatNumber(Form.Percentage.Value, "P", "en-US")}} | 1234 | 123,400.000% |
{{FormatNumber(Form.Percentage.Value, "P1", "en-US")}} | 1234 | 123,400.0% |
{{FormatNumber(HostSystem.Percentage, "P1", "nl-NL")}} | -0.39678 | -39,7 % |
|
Custom numeric format strings
Zero placeholder (0)
Replaces a zero with the corresponding digit if one is present, otherwise a zero appears in the result string.
Binding | Input | Output |
{{FormatNumber(Form.Amount.Price, "00000")}} | 12 | 00012 |
{{FormatNumber(Form.Amount.Price, "00000")}} | 123456 | 123456 |
{{FormatNumber(Form.Amount.Price, "00000")}} | -1234 | -01234 |
{{FormatNumber(HostSystem.Amount, "0.00", "en-US")}} | 0.45678 | 0.46 |
{{FormatNumber(HostSystem.Amount, "0.00", "nl-NL")}} | 0.45678 | 0,46 |
|
Digit placeholder (#)
Digit placeholder replaces the "#" symbol with the corresponding digit if one is present, otherwise no digit appears in the result string.
Note that no digit appears in the result string if the corresponding digit in the input string is a non-significant 0. For example, 0003 ("####") will return 3.
Binding | Input | Output |
{{FormatNumber(Form.Amount.Price, "#####")}} | 1234 | 1234 |
{{FormatNumber(HostSystem.Amount, "#####")}} | 1234.5678 | 1235 |
{{FormatNumber(HostSystem.Amount, "#.##", en-US)}} | 0.45678 | .46 |
{{FormatNumber(HostSystem.Amount, "#.##", nl-NL)}} | 0.45678 | ,46 |
|
Decimal point (.)
Decimal point determines the location of the decimal separator in the result string.
Binding | Input | Output |
{{FormatNumber(Form.Amount.Price, "0.00", "en-US")}} | 1234 | 1234.00 |
{{FormatNumber(Form.Amount.Price, "0.00", "nl-NL")}} | 1234 | 1.234,00 |
Group separator and Number scaling (,)
Serves as both a group separator and a number scaling specifier. As a group separator, it inserts a localized group separator character between each group. As a number scaling specifier, it divides a number by 1000 for each comma specified.
Group separator specifier
Binding | Input | Output |
{{FormatNumber(Form.Amount.Price, "##,#", "en-US")}} | 1234567890 | 1,234,567,890 |
{{FormatNumber(Form.Amount.Price, "##,#", "nl-NL")}} | 1234567890 | 1.234.567.890 |
Number separator specifier
Binding | Input | Output |
{{FormatNumber(Form.Amount.Price, "#,#,,", "en-US")}} | 1234567890 | 1,235 |
{{FormatNumber(Form.Amount.Price, "#,#,,", "nl-NL")}} | 1234567890 | 1.235 |
Percentage placeholder (%)
Percentage placeholder multiplies a number by 100 and inserts a localized percentage symbol in the result string.
Note: in these examples 'Form.Amount.Price' is replaced by 'Form.Percentage.Value'.
Binding | Input | Output |
{{FormatNumber(Form.Percentage.Value, "%#0.00", "en-US")}} | 12 | %1200.00 |
{{FormatNumber(Form.Percentage.Value, "##.0 %", "en-US")}} | 12 | 1200.0 % |
{{FormatNumber(Form.Percentage.Value, "##.0 %", "nl-NL")}} | 12 | 1200,0 % |
Per mille placeholder (‰)
Per mille placeholder multiplies a number by 1000 and inserts a localized per mille symbol in the result string.
Note: in these examples 'Form.Amount.Price' is replaced by 'Form.Permille.Value'.
Binding | Input | Output |
{{FormatNumber(Form.Permille.Value, "#0.00‰", "en-US")}} | 12 | 12000.00‰ |
{{FormatNumber(Form.Permille.Value, "#0.00‰", "nl-NL")}} | 12 | 12000,00‰ |
Escape character (\)
Escape character causes the next character to be interpreted as a literal rather than as a custom format specifier.
Binding | Input | Output |
{{FormatNumber(Form.Amount.Price, "\###00\#")}} | 1234 | #1234# |
Literal string delimiter (string)
Literal string delimiter indicates that the enclosed characters should be copied to the result string unchanged.
Note: in these examples 'Form.Amount.Price' is replaced by 'Form.Angle.Value'.
Binding | Input | Output |
{{FormatNumber(Form.Angle.Value, "# 'degrees'")}} | 12 | 12 degrees |
{{FormatNumber(Form.Angle.Value, "#' degrees'")}} | 12 | 12 degrees |
Section separator (;)
Section separator defines sections with separate format strings for positive, negative, and zero numbers.
Binding | Input | Output |
{{FormatNumber(Form.Amount.Price, "#0.0#;(#0.0#);-\0-")}} | 1234 | 1234,0 |
{{FormatNumber(Form.Amount.Price, "#0.0#;(#0.0#);-\0-")}} | 0 | -0- |
{{FormatNumber(Form.Amount.Price, "#0.0#;(#0.0#);-\0-")}} | -1234 | (1234,0) |
All other characters
All other characters: the character is copied to the result string unchanged.
Note: in this example 'Form.Amount.Price' is replaced by 'Form.Angle.Value'.
Binding | Input | Output |
{{FormatNumber(Form.Angle.Value, "# °")}} | 12 | 12 ° |
|
Related articles
Comments
0 comments
Article is closed for comments.