Functions Utility

TypeCast

The TypeCast() function takes a data range as input and casts the columns or rows of that range according to a specified list of data types.

Related functions: Transform


Syntax:

Qx.TypeCast(Range, Data Types, [Mode], [Cast Error Value])
  • In Excel with Quintessence add-in versions prior to 25.1, use: TypeCast()
  • In the Quintessence Editor (Studio) using Quintessence language, use: TypeCast()
  • In the Quintessence Editor (Studio) using Python language, use: Qx.TypeCast()
 See parameter descriptions

RangeThe range of data used as input.
Data TypesA comma separated list of data types to apply to the rows or columns.
One data type must be supplied for each row or column being cast.
Valid data type values:
text or t
number or n
date or d
boolean or b
Mode
(optional)
Specifies whether casting applies to columns or rows.
Cast Error Value
(optional)
The value to return when a cast fails.

Remarks:

  • The default parameters are:
    • Mode: Column
    • Cast Error Value: Value is left blank (empty)

Examples:

The examples provided below are based on fictitious data for illustrative purposes only.

> Example 1: Typecasting columns with specific error text


Range (A1:D3):

AAA1021
1/30/190020A12
3BBB41

Objective:

  • Convert column 1 → number
  • Convert column 2 → date
  • Convert column 3 → text
  • Convert column 4 → boolean
  • If any conversion fails, insert conversion failed

Function call:

=Qx.TypeCast(A1:D3, "n, d, t, b", , "conversion failed")

Result:

conversion failed1900/01/102TRUE
301900/01/20A1conversion failed
3conversion failed4TRUE
> Example 2: Typecasting rows with default error text


Range (A1:C2):

CCC102/18/1982
1010

Objective:

  • Convert row 1 → number
  • Convert row 2 → boolean
  • If any conversion fails, leave the value blank

Function call:

=Qx.TypeCast(A1:C2, "number, boolean", "row")

Result:

1030000
TRUEFALSE