Num - script and chart function
Num() formats a number, that is it converts the numeric value of the input to display text using the format specified in the second parameter. If the second parameter is omitted, it uses the decimal and thousand separators set in the data load script. Custom decimal and thousand separator symbols are optional parameters.
Syntax:
Num(number[, format[, dec_sep [, thou_sep]]])
Return data type: dual
The Num function returns a dual value with both the string and the numeric value. The function takes the numeric value of the input expression and generates a string representing the number.
Argument | Description |
---|---|
number | The text string to be evaluated. |
format |
String specifying how the resulting string is to be formatted. If omitted, the decimal and thousand separators that are set in the data load script are used.
The Num function supports many format options for different numeric structures, for example: #,##0: Displays a number without decimal places. #,##0.00: Displays a number with two decimal places. ##0.00%: Displays a number as a percentage with two decimal places. #,##0;(#,##0): Formats negative numbers to appear in parentheses. $#,##0.00: Formats numbers as currency with a $ symbol. 0.00E+0: Displays numbers in scientific notation. |
dec_sep |
String specifying the decimal number separator. If omitted, the value of the variable DecimalSep that is set in the data load script is used.
The Num function supports many decimal number separator formats, for example: Comma ' , ': For example, $1,000,00 for one thousand dollars. Period ' . ': For example, € 1,000.00. Hyphen ' - ': When used instead of the traditional period or comma for the decimal separator, it shows values like ¥1,000-00. For more information, see DecimalSep. |
thou_sep |
String specifying the thousands number separator. If omitted, the value of the variable ThousandSep that is set in the data load script is used.
The Num function supports many options for the thousands number separator: Period ' . ': Uses a period for the thousands separator (common in some European formats), displaying as $1.000,00 if combined with a comma decimal separator. Space ' ': Uses a space for the thousands separator, which is common in some European countries. Displays as € 1 000.00. Underscore '_': Uses an underscore for the thousands separator, which is sometimes used in technical or specific regional formats. Displays values like $1_000.00. For more information, see ThousandSep. |
For more information on number formatting see Conventions for number and time formats.
Example | Results (String value returned) |
---|---|
Num(35648.312) | Returns 35648.312 (depends on the environment variables in the script) |
Num(35648.312, '0.0', '.') | Returns 35648.3 |
Num(35648.312, '0,00', ',') | Returns 3,56,48 |
Num(35648.312, '#,##0.0', '.', ',') | Returns 35,648.3 |
Num(35648.312, '# ##0', ',', ' ') | Returns 35 648 |