Contents:
true
or false
.(left-hand side) (operator) (right-hand side)
These evaluations result in a Boolean output. The following operators are supported:
Operator Name | Symbol | Example Expression | Output | Notes |
---|---|---|---|---|
and | && |
| true | |
| false | |||
or | || |
| true | Exclusive or (xor) is not supported. |
| false | |||
not | ! |
| false | |
| true |
The above examples apply to integer values only. Below, you can review how the comparison operators apply to different data types.
Usage
Logical operators are used to perform evaluations of expressions covering a variety of data types. Typically, they are applied in evaluations of values or rows.
Example data:
X | Y |
---|---|
true | true |
true | false |
false | true |
false | false |
Transforms:
derive type:single value:(X && Y) as: 'col_and'
derive type:single value:(X || Y) as: 'col_or'
derive type:single value:!(or) as: 'col_not_and'
derive type:single value:!(or) as: 'col_not_or'
Results:
Your output looks like the following:
X | Y | col_and | col_or | col_not_and | col_not_or |
---|---|---|---|---|---|
true | true | true | true | false | false |
true | false | false | true | true | false |
false | true | false | true | true | false |
false | false | false | false | true | true |
Tip: For additional examples, see Common Tasks.Examples
and
Column Type | Example Transform | Output | Notes |
---|---|---|---|
Integer/Decimal | set col:InRange value:((Input >= 10) && (Input <= 90)) |
| |
Datetime | delete row: ((Date >= DATE(2014, 01, 01)) && (Date <= DATE(2014, 12, 31)) | Delete all rows in which the Date value falls somewhere in 2014. | |
String | derive type:single value:((LEFT(USStates,1) == "A") && (RIGHT(USStates,1) == "A")) | For U.S. State names, the generated column contains
For all other values, the generated value is |
|
or
Column Type | Example Transform | Output | Notes |
---|---|---|---|
Integer/Decimal | set col:BigOrder value:((Total > 1000000) || (Qty > 1000)) |
| |
Datetime | delete row: ((Date <= DATE(1950, 01, 01)) || (Date >= DATE(2050, 12, 31)) | Delete all rows in the dataset where the Date value is earlier than 01/01/1950 or later than 12/31/2050. | |
String | derive type:single value:((Brand == 'subaru') || ('Color' == 'green')) as:'good_car' |
|
not
Column Type | Example Transform | Output | Notes |
---|---|---|---|
Integer/Decimal | keep row:!((sqft < 1300) && (bath < 2) && (bed < 2.5)) | Keep all rows for houses that do not meet any of these criteria:
| |
Datetime | keep row:!(YEAR(Date) == '2016') | Keep all rows in the dataset where the year of the Date value is not 2016. | |
String | delete row:!(status == 'Keep_It') | Delete all rows in which the value of the status column is not Keep_It . |
|
This page has no comments.