Number Functions
Calculated Attribute expressions can be written using the following available functions. Use Cases follow the available functions table.
Number Function |
Parameters |
Description |
---|---|---|
Binary logical functions |
<, >, <=, >=, =,!= |
Returns 1 (=TRUE) or 0 (=FALSE). Note: These functions do NOT work on text strings since they attempt to convert to a number. |
Binary number functions |
+, -, *, / |
Returns the computed number of the operation. If possible, text is converted to a number. If number conversion fails, 'NaN' (meaning 'Not a Number') is returned. Note: Rounding errors can occur when using the binary number functions in number calculations. To correct rounding in these cases, use the ROUND or TEXT function. |
INT |
(number) |
Returns the integer part of ‘number’ by rounding down to the nearest integer. Negative numbers are rounded down, away from 0. This function works exactly the same as the TRUNC function for positive numbers. |
LOCALIZENUMBER |
(number[, locale]) |
Localizes the number to a string, using the locale in the current / extracting / resolving context, or using the supplied locale. [locale] is optional; refer to Using a Locale below |
ROUND |
(number, precision) |
Returns ‘number’, rounded to a specified number of digits, controlling the number of decimal places.
|
TEXT |
(number, format string) |
Returns a textual representation of the supplied number, formatted by the supplied formatting string. |
TRUNC |
(number) |
Returns the integer part of ‘number’ by removing the decimal and any numbers following it. No rounding is performed. Also, refer to the INT function in this topic. |
Using a Locale
When using calculations on numbers, use the LOCALIZENUMBER() and specify a locale ID that uses a 'dot-is-decimal' method (for example, 12.34) and not a 'comma-is-decimal' method (for example, 12,34). After the calculation, use the function again to convert the decimal point value to the required locale's format. Ensure the following property is defined in the sharedconfig.properties file:
Calculated.UseLegacyLocalization=true
For more information on locales, refer to Context Locales documentation in this guide here.
Use Cases
For examples of these functions, refer to Number Examples here.