 Logical operators (and, or, not) enable you to logically combine multiple expressions to evaluate a larger, more complex expression whose output is true or false.
 (left-hand side) (operator) (right-hand side)

These evaluations result in a Boolean output. The following operators are supported:

Operator NameSymbolExample ExpressionOutputNotes
and&&

((1 == 1) && (2 == 2))

true

((1 == 1) && (2 == 3))

false
or||

((1 == 1) || (2 == 2))

trueExclusive or (xor) is not supported.

((1 == 2) || (2 == 3))

false
not!

!(1 == 1)

false

!(1 == 2)

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:

XY
truetrue
truefalse
falsetrue
falsefalse

Transforms:    Results:

Your output looks like the following:

XYcol_andcol_orcol_not_andcol_not_or
truetruetruetruefalsefalse
truefalsefalsetruetruefalse
falsetruefalsetruetruefalse
falsefalsefalsefalsetruetrue and

Column TypeExample TransformOutputNotes
Integer/Decimal • Set the value of the InRange column to true if the value of the Input column is between 10 and 90, inclusive.
• Otherwise, InRange column is false.

Datetime Delete all rows in which the Date value falls somewhere in 2014.
String For U.S. State names, the generated column contains true for the following values:

• Alabama
• Arizona

For all other values, the generated value is false.

or

Column TypeExample TransformOutputNotes
Integer/Decimal • In the BigOrder column, set the value to true if the value of Total is more than 1,000,000 or the value of Qty is more than 1000.
• Otherwise, the value is false.

Datetime Delete all rows in the dataset where the Date value is earlier than 01/01/1950 or later than 12/31/2050.
String • Generate the new good_car column containing true if the Brand is subaru or the Color is green.
• Otherwise, the good_car value is false.

not

Column TypeExample TransformOutputNotes
Integer/Decimal Keep all rows for houses that do not meet any of these criteria:

• smaller than 1300 square feet,
• less than 2 bathrooms,
• less than 2.5 bedrooms.

Datetime Keep all rows in the dataset where the year of the Date value is not 2016.
String Delete all rows in which the value of the status column is not Keep_It.

 See Also 