VALUE( ) function

Converts a character string to a numeric value.

Syntax

VALUE(string, decimals)

Parameters

Name Type Description
string

character

The field, literal, or expression to convert.

decimals numeric

The number of decimal places to include in the output.

Output

Numeric.

Examples

Basic examples

Returns -123.400:

VALUE("123.4-", 3)

Returns 123456.00:

VALUE("$123,456", 2)

Returns -77.45:

VALUE("77.45CR", 2)

Returns -123457:

VALUE(" (123,456.78)", 0)

Field input

Returns character values in the Salary field as numbers without any decimal places:

VALUE(Salary, 0)

Remarks

How it works

This function converts character data to numeric data. You can use the VALUE( ) function if you need to convert character expressions or field values to numeric values for use in Analytics commands.

Numeric input formatting

VALUE( ) accepts numbers in any format. You can use any numeric formatting accepted by the Print data type such as punctuation, leading or trailing signs, and parentheses as input.

Negative values

The VALUE( ) function can interpret different indicators of negative values such as parentheses and the minus sign. It can also interpret CR (credit) and DR (debit). For example:

Returns -1000.00:

VALUE("(1000)", 2)
VALUE("1000CR", 2)

Decimal vs integer values

If the string value does not include decimals, Analytics treats the number as an integer. For example:

Returns 123.00:

VALUE("123", 2)

If the number of decimals specified by decimals is less than the number in the field or expression, the result is rounded. For example:

Returns "10.6":

VALUE("10.56", 1)

Related functions

The VALUE( ) function is the opposite of the STRING( ) function, which converts numeric data to character data.