Number patterns

This page explains how to define a pattern to output a certain number in a certain way. You specify the pattern according to the rules and elements specified below.

You can specify custom number patterns in the formatNumber functions, or in the custom number option as described on this page:

Elements of a pattern

A pattern consists of numerical elements and, optionally, static elements. Numerical elements represent a digit, a currency sign, a percentage, a decimal separator etc. Static elements are parts you can include yourself, such as words.

Location of elements

Some elements can only be used in a specific location inside the pattern. Here are the locations:

  • Prefix - everything that comes before the number
  • Number - the number itself
  • Suffix - everything that comes after the number

For instance, in '€12' the euro sign is the prefix. In '12 dollars', dollars is the suffix.

Numerical elements

 symbol meaning location extra info
0 forced digit number Forced means that even if it's zero, it will appear.
# unforced digit number Unforced means that this digit will not be shown if it's zero and is at the beginning or the end of a number.
. decimal separator number  
, grouping separator number Also known as 1000 separator.
E mantissa & exponent separator in scientific notation number  
; subpattern separator in between 2 subpatterns (see Subpatterns)  
% percentage prefix or suffix Including this will multiply the number by 100.
‰ (\u2030) per mille prefix or suffix Including this will multiple the number by 1000.
¤ (\u00A4) currency symbol prefix or suffix The used symbol depends on the locale as set on the Smart Flows server. If you use formatNumberR, you can specify the locale to use.

Static elements

You can use both symbols and letters as static elements. You can use the following symbols by putting them directly in the pattern:

/ * - + & ! ( ) { } [ ] , . ; : < > _ - # @

If you want to use a ' (apostrophe), you need to put 2 of them, like this:

''

If you want to use letters, you need to put them in between apostrophes, like this:

'a'  'dollars'  'a fistful of dollars'

Defining a pattern

In the mapping window

When you have a number in a field, or as the output of an expression, you can use the custom number option in the Format tab of the mapping window to specify a pattern:

In an expression

Defining a pattern in an expression is necessary for the formatNumber and formatNumberR functions:

formatNumber(512.4568,'##.##')formatNumber(512.4568,'000,000.000')

As always with expressions, you need to put strings (such as a number pattern) in between ' ' (apostrophes). This, however, makes it a bit harder to use letters in your patterns, as you can't simply use apostrophes, since those are used to delineate the beginning and ending of the pattern in an expression.

To remedy this, you can escape your apostrophes by putting a \ (backslash) in front of them. So, instead of...

## 'dollars' 

...you type this:

## \'dollars\' 

It may look a bit strange, but it will definitely get the job done. Here's an example of the above pattern: Notice the apostrophe before and after the entire pattern:

formatNumber(512,'## \'dollars\'')

Subpatterns

A pattern can consist of 2 subpatterns: one for the positive representation and one for the negative representation.

The negative subpattern is optional. If you don't include it, the localized minus sign (usually - ) is used in front of the positive representation to represent negative numbers.

Specifyin a negative subpattern is done after putting a ; following the positive subpattern. If there is an explicit negative subpattern, it serves only to specify the negative prefix and suffix. The number of digits, minimal digits, and other characteristics are all the same as the positive pattern. That means that "#,##0.0#;#" produces precisely the same behavior as "#,##0.0#;#,##0.0#".

For instance, '##.##;°' will output °30.33 (for a value of -30.33).