Skip to main content

NUMVALUE Function

Converts a string formatted as a number into an Integer or Decimal value by parsing out the specified decimal and group separators. A string or a function returning formatted numbers of String type or a column containing formatted numbers of string type can be inputs.

You can use this function to convert String values that have locale-specific formatting to locale-independent values of Integer or Decimal type by removing the formatting separators.

  • If the source value does not include a valid input for this function, a missing value is returned.

  • This function supports negative input values.

  • Supports input for multiple locale types and returns the output of the appropriate numeric type.

You can use decimal separators and grouping separators when working with other currency formats. More information is below.

Anmerkung

If the decimal separator and group separator arguments are not specified, then a null value is returned.

Wrangle vs. SQL: This function is part of Wrangle, a proprietary data transformation language. Wrangle is not SQL. For more information, see Wrangle Language.

Basic Usage

Numvalue(<code>Discount</code>, &quot;<code>,</code>&quot; ,&quot;<code>.&quot;</code>)

Output: Returns the values from the Discount column by converting the formatted number to a numeric value using decimal and group separators. For example, if the Discount column has values in percentage, then it is converted into the corresponding numeric value. Example: 10% to 0.10.

Anmerkung

If multiple percent signs are used in a column, then this function returns the decimal values accordingly. For example, an input of 9%% returns 0.0009.

Anmerkung

This function removes any currency indicators. For example, £ 100 as an input value returns 100.

Syntax and Arguments

<code class="listtype-code listindent1 list-code1 lang-bash">Numvalue(formattedNumber, [&quot;grouping_separator&quot;], [&quot;decimal_separator&quot;])</code>

Argument

Required?

Data Type

Description

formattedNumber

Y

string

A string, a column of strings, or a function returning a string

grouping_separator

Y

string

A grouping representing grouping separator. By default, comma (,) is used as the grouping separator.

decimal_separator

Y

string

A string used to separate the integer and fractional part of the result. If not specified, then a null value is returned.

For more information on syntax standards, see Language Documentation Syntax Notes.

formatted_number

Literal string value, a function that returns a string value, or the name of a column containing string values to be converted into a numeric value.

  • Multiple columns and wildcards are not supported.

Usage Notes:

Required?

Data Type

Example Value

Yes

string, a column of strings, or a function returning a formatted number string or column of strings

Discount

grouping_separator

The string used to group a set of digits in the input values. Separators must be enclosed with double quotes (") or single quotes ('). For example, a comma (,) is used as a grouping separator in the U.S.A. (“10,000”), whereas space is used in France (“10 000”).

Anmerkung

When you provide invalid separators or wrong separators, you may get an error in the Formula column.

Usage Notes:

Required?

Data Type

Example Value

Yes

String literal

','

decimal_separator

The string used to indicate the decimal point in the input values. Separators must be enclosed with double quotes (") or single quotes (').

A decimal separator is used to separate the fractional part of a number written in decimal form. For example, a period (.) is used as a decimal separator in the U.S.A. ("1234.12"), whereas comma (,) is used in France ("1234,12").

Usage Notes:

Required?

Data Type

Example Value

Yes

String literal

'.'

Grouping Separator

Decimal Separator

Example Locale

Comma (,)

Period (.)

U.S locale

Period (.)

Comma (,)

Spanish locale

Space

Comma (,)

French locale

Examples

Tipp

For additional examples, see Common Tasks.

Example - formatting price and percentages

This example shows how to convert the formatted number of string type into a numeric value. The following table shows different types of products and their total sales in the UK region. From this example, you must convert the total sales value for the U.S region.

First, you must convert the global currency formats into a generic numeric value, then proceed with the conversion calculation.

Source:

Products

Total_Sales_UK

Baby Foods

£ 100.00

Medicines

£ 150.00

Groceries

£ 200.00

Kitchen Supplies

£ 25.00

Cosmetics

£ 250.00

Snacks

£ 50.00

Transformation:

The first transformation is to convert the Total_Sales_UK column into a numeric value. In this case, when a Numvalue function is applied, the value with the currency symbols returns only the numeric value. You can see the currency symbol is removed when using the Numvalue function.

Transformation Name

Edit column with formula

Parameter: columns

Total_Sales_UK

Parameter: Formula

NUMVALUE (Total_Sales_UK, ",",".")

The second step consists of converting the U.K Pounds (£) to U.S Dollars ($) for better computations. In this step, you multiply the Total_Sales_UK column with the ratio conversion rate. Let's say the current conversion rate is 1.36, then multiply the U.K Pounds with 1.36 to convert to U.S Dollars. As a part of this transformation, the Total_Sales_US column is created.

Transformation Name

New formula

Parameter: Formula type

Single row formula

Parameter: Formula

Total_Sales_UK * 1.36

Parameter: New column name

Total_Sales_US

After you get the U.S conversion, you can format the values using the Numformat function. The Numformat function formats a numeric set of values according to the specified number formatting.

Transformation Name

Edit column with formula

Parameter: columns

Total_Sales_US

Parameter: Formula

NUMFORMAT(Total_Sales_US, '$###,###.00', ',', '.')

Results

The output data should look like the following:

Products

Total_Sales_UK

Total_Sales_US

Baby Foods

£ 100.00

$136.00

Medicines

£ 150.00

$204.00

Groceries

£ 200.00

$272.00

Kitchen Supplies

£ 25.00

$34.00

Cosmetics

£ 250.00

$340.00

Snacks

£ 50.00

$68.00