Excerpt |
---|
The IFMISMATCHED function writes out a specified value if the input expression does not match the specified data type or typing array. Otherwise, it writes the source value. Input can be a literal, a column reference, or a function. |
The ISMISMATCHED
function simply tests if a value is mismatched. See ISMISMATCHED Function.
Basic data type:
D lang syntax |
---|
RawWrangle | true |
---|
Type | ref |
---|
showNote | true |
---|
WrangleText | derive type:single value:ifmismatched(my_ssn,'SSN', 'XXX-XX-XXXX') as:'final_SSN' |
---|
|
ifmismatched(my_ssn,'SSN', 'XXX-XX-XXXX') |
Output: Returns the value XXX-XX-XXXX
if the value in my_ssn
does not match the SSN
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 lang syntax |
---|
RawWrangle | true |
---|
Type | ref |
---|
showNote | true |
---|
WrangleText | set col: month_Date value: ifmismatched(month_Date, ['Datetime','mm-dd-yy','mm*dd*yy'], null()) |
---|
|
ifmismatched(month_Date, ['Datetime','mm-dd-yy','mm*dd*yy'], null()) |
Output: Returns null if values in month_Date
are mismatched against Datetime values in the mm-dd-yy
or mm*dd*yy
formats.
D lang syntax |
---|
RawWrangle | true |
---|
Type | syntax |
---|
showNote | true |
---|
WrangleText | derive type:single value:ifmismatched(column_string, data_type_literal, computed_value) |
---|
|
ifmismatched(column_string, data_type_literal, computed_value) |
Argument | Required? | Data Type | Description |
---|
source_value | Y | string | Name of column, string literal or function to be tested |
datatype_literal | Y | string | String literal or array that identifies the data type against which to validate the source values |
output_value | y | string | String literal value to write |
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.
Required? | Data Type | Example Value |
---|
Yes | String literal, column reference, or function | myColumn |
datatype_literal
Literal value or string array that identifies data type to which to validate the source column or string.
- Column references are not supported.
Required? | Data Type | Example Value |
---|
Yes | String 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 mismatched for the specified data type.
Required? | Data Type | Example Value |
---|
Yes | String or numeric literal | 'Data type mismatch' |
Example - IF* functions for data type validation
Include Page |
---|
| EXAMPLE - IF Data Type Validation Functions |
---|
| EXAMPLE - IF Data Type Validation Functions |
---|
|