Format Number function
The Format Number function returns a string that is a number formatted to fit the specified pattern.
Parameter: number
The number to format. This can come from a source node, the result of another function, or a value that you specify.
Parameter: string
- Required digits = 0
- Optional digits = #
- Minus symbol = -
- Decimal symbol = .
- Grouping separator = ,.Typically used to separate groups of three digits.
- Percent symbol = %. When the percent symbol is present, the input number is multiplied by 100 and the result is shown as a percentage.
- Per mille symbol = (Unicode x2030). This symbol multiplies the number by 1000 and shows the result as a per mille.
- Positive/negative separator = ;
- Infinity = infinity
- Not a number = NaN
- $ = $
- $#,##0.00 – formats a number in the standard format for United States dollars with the dollar sign, commas for separators and at least one dollar digit and two digits for cents.
- #0.000% – formats a decimal number as a percentage with at least three decimal places.
- #,##0.00;(#,##0.00) – formats negative number with parentheses, a format commonly used in accounting.
Returns: string
The first parameter reformatted to reflect the pattern specified by the second parameter.
Examples
Patterns can have constant text as a prefix, suffix, or both. Common uses are to specify the currency symbol or some unit of measurement.
Example 1$#,##0.00 – formats a number in the standard format for United States dollars with the dollar sign, commas for separators and at least one dollar digit and two digits for cents.
format-number(12345.6789,'$#,##0.00') = '$12,345.67'#0.000% – formats a decimal number as a percentage with at least three decimal places.
format-number(.67890123,'#0.000%') = '67.890%'When the percent symbol is present, the input number is multiplied by 100.
Example 3#,##0.00;(#,##0.00) – formats negative number with parentheses, a format commonly used in accounting.
format-number(-12345.6789,'#,##0.00;(#,##0.00)') = '(12,345.67)'