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

A pattern that specifies how the first parameter should be formatted. This pattern uses these symbols to define the pattern:
  • 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
  • $ = $
Patterns can have constant text as a prefix, suffix, or both. Common uses are to specify the currency symbol or some unit of measurement.
  • $#,##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'
Example 2

#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)'



Feedback | Notices


Timestamp icon Last updated: Wednesday, 15 June 2016


http://pic.dhe.ibm.com/infocenter/wci/v7r0m0/topic/com.ibm.wci.doc/ref_Format_Number.html