The FormatNumber function will take a numeric value and format it in various ways, as controlled by a pattern string.
Here follow some examples which include further formatting parameters:
«FormatNumber(Age,"0.0")»Where the value of ‘Age’ is 100, the result will be 100.0.
«FormatNumber(Number,"0")»Where the value of ‘Number’ is 3, the result will be 3 (no decimal places).
Where ‘Amount’ is 9876, the result will be 9,876.00 (the default format).
Where the value of ‘Price’ is 123456, the result will be R123 456,00. Note that the decimal format code “ZA” is required to indicate that the decimal point and thousands separator should be according to official South African format (as required, for example, by the South African Deeds Registry). Note also that the decimal format code “EU” will format the number according to European decimal rules, that is a full stop as the thousands separator and a comma as the decimal point.
Other options for the decimal format code (or zone) are: “US” (the default), “FR” which is the same as “ZA”, and “CX” which will render the thousands separator as a space and the decimal as a full stop (period).
Where ‘Balance’ is 123456.78 the result is 123,456.78
Where ‘Balance’ is -123456.78 the result will be (123,456.78).
For a Taxable_Income of 98765.43 the result will be 98.765
Where ‘ID_Number’ is 7811145001080 the result will be 781114-5001-080.
Note that the parameters of formatting functions (as against those of layout commands) must be enclosed in single or double quotes, unless their value is contained in a data element, in which case the data element name is not enclosed in quotes. In other words, it is those quotes, or their absence, that lets XpressDox know you want a formatting parameter as typed in the command, or as extracted from the data set, respectively. More extensive coverage is given in Notes on XpressDox syntax and also in Commands and Functions
Please also see the article The RenderAsNumeric function which shows how to make sure that the value typed in by a user can be made to be numeric regardless of the format in which they enter the value. There is also a discussion in the article Tips and Hints using the Rule Command about using Rule together with FormatNumber.
The Question command in v14:
The concept of Low Code authoring was introduced in v14, and with that the Question command. It is now possible to insert a Number Question into the template without the need for FormatNumber. Inside the Question command, state that it is a number and select your desired format.