TO_DECIMAL
Description
TO_DECIMAL
is a row function that converts TEXT
, BOOLEAN
, INTEGER
, LONG
, DOUBLE
, or NUMERIC
values to NUMERIC
values with the default number of digits before and after the decimal point.Syntax
TO_DECIMAL
(expression
)Return Value
Returns one value per row of type
NUMERIC
with the default number of digits before and after the decimal point.Input Parameters
- expression
- Required. A field or expression of typeTEXT(must be numeric characters),BOOLEAN,INTEGER,LONG,DOUBLE, orNUMERIC.
Examples
Convert the values of the
average_rating
field to a Numeric field type:TO_DECIMAL([average_rating])
Convert the
average_rating
field to a Numeric field type, but first transform the occurrence of any NA
values to NULL
values using a CASE
expression:TO_DECIMAL(CASE WHEN [average_rating]="N/A" then NULL ELSE [average_rating] END)