Page tree

 

Support | BlogContact Us | 844.332.2821

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

D toc
Excerpt

The IFVALID function writes out a specified value if the input expression matches the specified data type. Otherwise, it writes the source value. Input can be a literal, a column reference, or a function.

 

The VALID function simply tests if a value is valid. See VALID Function.

D s
snippetBasic

D code

derive value:IFVALID(myZip,'ZipCode', 'ok') as:'myZipCheck'

Output: Generates a new column called, myZipCheck, which contains the value ok if the value in myZip matches the ZipCode data type. 

Data type with formatting options:

For data types with formatting options, such as Datetime, you can specify the format using an array, as in the following:

D code

set col: validDate value: IFVALID(myDate, ['Datetime','mm-dd-yy','mm*dd*yy'], 'true')

Output: Sets the values in the validDate column to true, if the corresponding value in the myDate column is a valid Datetime value in yy-mm-dd or yy*mm*dd format.

D s
snippetSyntax

D code

derive value:IFVALID(column_string, data_type_literal, computed_value)

ArgumentRequired?Data TypeDescription
source_valueYstringName of column, string literal or function to be tested
datatype_literalYstringString literal that identifies the data type against which to validate the source values
output_valueystringString literal value to write

D s lang notes

source_value

Name of the column, string literal, or function to be tested for data type matches.

  • Missing literals or column values generate missing string results.
  • Multiple columns and wildcards are not supported.

D s
snippetusage

Required?Data TypeExample Value
YesString literal, column reference, or functionmyColumn

datatype_literal

Literal value for data type to which to validate the source column or string.

  • Column references are not supported.

D s
snippetusage

Required?Data TypeExample Value
YesString literal'Integer'

Valid data type strings:

Include Page
Valid Data Type Strings
Valid Data Type Strings

output_value

The output value to write if the tested value is valid for the specified data type.

D s
snippetusage

Required?Data TypeExample Value
YesString or numeric literal'Data type mismatch'

D s
snippetExamples

Example - IF* functions for data type validation

Include Page
EXAMPLE - IF Data Type Validation Functions
EXAMPLE - IF Data Type Validation Functions

D s also
labeltype