QQ - How do I cast between different data types?
  • 2 Minutes to read
  • Dark
    Light
  • PDF

QQ - How do I cast between different data types?

  • Dark
    Light
  • PDF

Article summary

Article In Progress...

In general data should be loaded into a system so that field-data types are well matched, but this is not always possible.   The following functional areas may require field-data types to be changed:

  • Joins - there are limitations around which kind of continuous fields can be joined together - generally field-data types need to match exactly when linking continuous data-types.
  • Profiles - continuous fields cannot be profiled
  • Context Panel - quick counts are not displayed for continuous fields
  • Functions - some functions only accept a particular field-data type

The following functional areas support casting of data types:

  • String Functions:  LCAST, DCAST, ICAST, WILDICAST, WILDDCAST, CTOD, CONCAT
  • LMath: A  (Convert Double to Int)
  • DMath: A (Convert Int to Double)
  • Expression Builder: Explicitly set Target Datatype

String

FromToDetails
STRING DISCRETESTRING DISCRETE
  • STRING| CONCAT(A)
STRING DISCRETESTRING CONTINUOUS
  • STRING | ICAST (check "Do Not Ordinalize")
STRING DISCRETEINTEGER DISCRETE
  • STRING | ICAST
STRING DISCRETEINTEGER CONTINUOUS
  1. STRING | CONCAT (A) (check "Do Not Ordinalize") 
  2. STRING | ICAST
STRING DISCRETEDOUBLE DISCRETE
  • STRING | DCAST
STRING DISCRETEDOUBLE CONTINUOUS
  1. STRING | CONCAT (A) (check "Do Not Ordinalize") 
  2. STRING | DCAST
STRING DISCRETEDATE
  • STRING | DATEFROMSTRING(A,B)
STRING DISCRETEDATETIME
STRING DISCRETELONGINTEGER DISCRETE
  • STRING | LCAST
STRING DISCRETELONGINTEGER CONTINUOUS
  1. STRING | CONCAT (A) (check "Do Not Ordinalize") 
  2. STRING | LCAST
STRING CONTINUOUSSTRING DISCRETEMay not be possible, depending on cardinality of the source field.   To find the number of discrete values, use Field Audit or Data Audit
  • Use: 
    • STRING| CONCAT(A)   or
    • STRING | CTOD
      • If number of discrete values is too high to be stored in a discrete field, the threshold can be modified by changing MAX_ENTRIES in the JSON method (note - this can only be done in Script Editor and will impact system performance as the UI will attempt to display all discrete values)  
  • Consider applying a filter to reduce the number of discrete values
STRING CONTINUOUSSTRING CONTINUOUS
  • STRING| CONCAT(A) to create a copy of the field
STRING CONTINUOUSINTEGER DISCRETE
  • STRING | ICAST - it may be necessary to apply a filter to force the field to be discrete
STRING CONTINUOUSINTEGER CONTINUOUS
  • STRING | ICAST
STRING CONTINUOUSDOUBLE DISCRETE
  • STRING | DCAST - it may be necessary to apply a filter to force the field to be discrete
STRING CONTINUOUSDOUBLE CONTINUOUS
  • STRING | DCAST
STRING CONTINUOUSLONGINTEGER DISCRETE
  1. STRING | CTOD  (use MAX_ENTRIES to set a higher discrete threshold if necessary, or apply a filter to reduce the number of discrete values)
  2. STRING | LCAST
STRING CONTINUOUSLONGINTEGER CONTINUOUS
  • STRING | LCAST 
STRING CONTINUOUSDATE
  • STRING | DATEFROMSTRING(A,B)
STRING CONTINUOUSDATETIME


Integer

FromToDetails
INTEGER DISCRETEINTEGER CONTINUOUS
  1. STRING | CONCAT (A) (check "Do Not Ordinalize")
  2. STRING | ICAST
INTEGER DISCRETESTRING DISCRETE
  • STRING| CONCAT(A) to create a copy of the field
INTEGER DISCRETESTRING CONTINUOUS
  • STRING | CONCAT (A) (check "Do Not Ordinalize") 
INTEGER DISCRETEDOUBLE DISCRETE
  • STRING | DCAST
INTEGER DISCRETEDOUBLE CONTINUOUS
  1. STRING | CONCAT (A) (check "Do Not Ordinalize")
  2. STRING | DCAST
INTEGER DISCRETELONGINTEGER DISCRETE
INTEGER DISCRETELONGINTEGER CONTINUOUS
INTEGER DISCRETEDATE / DATETIMENA
INTEGER CONTINUOUSINTEGER DISCRETE
INTEGER CONTINUOUSSTRING DISCRETE
INTEGER CONTINUOUSSTRING CONTINUOUS
INTEGER CONTINUOUSDOUBLE DISCRETE
INTEGER CONTINUOUSDOUBLE CONTINUOUS
INTEGER CONTINUOUSDATE / DATETIMENA


LongInteger

FromToDetails
LONGINTEGER DISCRETEINTEGER CONTINUOUS
  1. STRING | CONCAT (A) (check "Do Not Ordinalize")
  2. STRING | ICAST
LONGINTEGER DISCRETESTRING DISCRETE
  • STRING| CONCAT(A) to create a copy of the field
LONGINTEGER DISCRETESTRING CONTINUOUS
  • STRING | CONCAT (A) (check "Do Not Ordinalize") 
LONGINTEGER DISCRETEDOUBLE DISCRETE
  • STRING | DCAST
LONGINTEGER DISCRETEDOUBLE CONTINUOUS
  1. STRING | CONCAT (A) (check "Do Not Ordinalize")
  2. STRING | DCAST
LONGINTEGER DISCRETEINTEGER DISCRETE
LONGINTEGER DISCRETEINTEGER CONTINUOUS
LONGINTEGER DISCRETEDATE / DATETIMENA
LONGINTEGER CONTINUOUSINTEGER DISCRETE
LONGINTEGER CONTINUOUSINTEGER CONTINUOUS
LONGINTEGER CONTINUOUSSTRING DISCRETE
LONGINTEGER CONTINUOUSSTRING CONTINUOUS
LONGINTEGER CONTINUOUSDOUBLE DISCRETE
LONGINTEGER CONTINUOUSDOUBLE CONTINUOUS
LONGINTEGER CONTINUOUSDATE / DATETIMENA

Double 

FromToDetails
DOUBLE DISCRETEDOUBLE CONTINUOUS
DOUBLE  DISCRETESTRING DISCRETE
DOUBLE  DISCRETESTRING CONTINUOUS
DOUBLE  DISCRETEINTEGER DISCRETE
DOUBLE  DISCRETEINTEGER CONTINUOUS
DOUBLE  DISCRETELONGINTEGER DISCRETE
DOUBLE  DISCRETELONGINTEGER CONTINUOUS
DOUBLE  DISCRETEDATE
DOUBLE  DISCRETEDATETIME
DOUBLE CONTINUOUSDOUBLE DISCRETE
DOUBLE CONTINUOUSSTRING DISCRETE
DOUBLE CONTINUOUSSTRING CONTINUOUS
DOUBLE CONTINUOUSINTEGER DISCRETE
DOUBLE CONTINUOUSINTEGER CONTINUOUS
  • LMATH | A
DOUBLE CONTINUOUSLONGINTEGER DISCRETE
DOUBLE CONTINUOUSLONGINTEGER CONTINUOUS
DOUBLE CONTINUOUSDATE
DOUBLE CONTINUOUSDATETIME


Date and Datetime

FromToDetails
DATEDATETIME
DATETIMEDATE
DATESTRING DISCRETE
DATESTRING CONTINUOUS
DATETIMESTRING DISCRETE
DATETIMESTRING CONTINUOUS
STRING DISCRETEDATE
STRING CONTINUOUSDATE
STRING DISCRETEDATETIME
STRING CONTINUOUSDATETIME




Was this article helpful?