Formatting numbers

Docmosis allows you to control how numbers are displayed in the finished document.

For example: the raw data may have numbers like: 1234.5.

Using the built-in function numFormat the number can be formatted so that it looks like this: $1,234.50.

Examples

It is best to view the TEMPLATE and OUTPUT files side-by-side to understand the formatting that has been applied.

The numFormat function 

The numFormat function requires two parameters, value and format, as shown in the syntax:

numFormat ( value, format )

The first is the value to be formatted and the second is a format string that describes the format to be applied.

The value can be taken directly from the data or the result of a calculation. 

The format string should be enclosed in single quotes, as in this example: '$#,###.00'.

Constructing the format string

The format string can contain:

# Hash represents any digit. If the # appears on the right of the decimal then a digit will only be shown if it is not zero. So trailing zeroes are not shown.
0 Zero represents any digit.  A digit will always be shown.  The result will be padded with leading or trailing zeroes as needed.
. If a decimal point is present in the format string then the desired number of digits after the decimal point can be described using a # or 0. The number of digits before the point will expand to match the value being formatted.
, This is commonly used as the thousands separator. If a , (comma) appears in the format string, then the number of digits between the , (comma) and the . (decimal point) will be repeated in blocks. Most common is 3 digits.
% If a percent character appears in the format then the value will be interpreted as a percentage, i.e. the value will be multiplied by 100, then the format will be applied to the result.
other characters Any other characters at that start or finish of the format string will also appear in the formatted result.  This is useful for adding currency symbols such as $ (dollar) ,£ (pounds) , etc. at the start of a number for prices/totals/monetary amounts or adding units of measurement at the end of a number for weight/distance/etc.

Other formatting options

Please read the Template Guide for the full list of formatting options including displaying numbers/money using the conventions from different geographic locales.

Feedback

Invalid Input

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam. Please also consider contacting support@docmosis.com if you need help with this article.

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam.

Invalid Input