Numeric Formatting

You can use .NET formatting specifiers to have the data stored in tokens automatically formatted to specified numeric settings. Standard format specifiers can be used to format numbers according to some of the most frequently used choices. Custom format specifiers work for the same options allowed by the standard ones and also allow you to further customize or combine formatting choices. You can type these specifiers directly in the tokens or use the token editor to insert the specifier and test the formatted token.

Example: Lisa is processing order forms. She wants to use the numbers in the "Order" field as document names. The order numbers can have various numbers of digits, so she wants to add leading zeros so the names will be sorted in true numeric order. Currently, the maximum number of digits in an order number is five, but she decides to allow eight digits so she can continue to use the same system well into the future. She can do this using either standard or custom numeric format specifiers. In either case, she can begin by opening the token editor and selecting Apply Formatting. Then she can use either of the following options: "%(Order#"D8")" or "%(Order#"00000000"#)". When tested with "334", both formats return "00000334".

Standard Numeric Format Specifiers

The following specifiers can be used to format numbers according to standard rules.

Example: Maggie creates a workflow that retrieves text from a document. The reports include numbers in decimal form that she wants to store as percentages. She can format the token as "%(RetrieveDocumentText_Text#"P"#)". When tested with ".12", she receives "12.00%".

Standard Numeric Strings
Specifier Type Function
C or c Currency Formats to local currency.
D or d Decimal Formats numbers before a decimal point and appends leading zeroes (e.g., "D8" for a minimum of eight digits).
E or e Exponent Formats number of digits in exponent (e.g., "e3" for three digits after decimal. "12345.6789" returns "1.235e+004").
F or f Fixed point Formats numbers after a decimal point (e.g., "F3" for three digits after the decimal).
P or p Percent Formats to percentage.

To learn more about standard numeric formatting specifiers, see the Microsoft Docs site.

Custom Numeric Format Specifiers

The following specifiers can be combined to format numbers to specific patterns.

Example: Maggie creates a workflow that retrieves text from a document. She wants to format the value of the corresponding token so that the numbers before the decimal place have a comma separating the thousands place, if one exists, but she does not want to append leading zeroes. She also wants the numbers to have exactly four digits after the decimal, even if that means appending zeroes. She can format the token as "%(RetrieveDocumentText_Text#"#,###.0000"#)". When tested with "1425.99", she receives "1,425.9900". When tested with "623.877", she receives "623.8770".

Custom Numeric Strings
Specifier Type Function
0 Zero placeholder Formats number of places. A zero appears if no value in a position.
# Digit placeholder Formats number of places. Nothing appears if no value in a position.
. Decimal point Represents location of decimal separator.
, Thousand separator and number scaling Insert comma (e.g. "0,," on "3,000,000" returns 3).
% Percentage placeholder Formats to percentage (e.g., "###%" on "0.09" returns 9%; "000%" returns 009%).
E0, E+0, E-0, e0, e+0, e-0 Scientific notation Formats displayed exponent. "0" indicates the minimum number of digits.
\ Escape character Interprets next character literally.
'ABC' or "ABC" Literal string Interprets strings in quotes literally.
; Section separator Formats first of three numbers for positives, second for negatives, third for zeros.

To learn more about custom numeric formatting specifiers, see the Microsoft Docs site.