Returns
true
if both arguments evaluate to true
. Equivalent to the &&
operator.- Each argument can be a literal Boolean, a function returning a Boolean, or a reference to a column containing Boolean values.
Since the AND
function returns a Boolean value, it can be used as a function or a conditional.
NOTE: Within an expression, you might choose to use the corresponding operator, instead of this function. For more information, see Logical Operators.
Basic Usage
derive type:single value: AND(finalScoreEnglish >= 60, finalScoreMath >=60) as:'promoteStudent'
Output: If the values in the finalScoreEnglish
and finalScoreMath
columns are greater than or equal to 60
, then the value in the new promoteStudent
column is true
. Otherwise, the value is false
.
Syntax and Arguments
derive type:single value:AND(value1, value2)
Argument | Required? | Data Type | Description |
---|---|---|---|
value1 | Y | string | The first value must be a Boolean literal, column reference, or expression that evaluates to true or false . |
value2 | Y | string | The first value must be a Boolean literal, column reference, or expression that evaluates to true or false . |
For more information on syntax standards, see Language Documentation Syntax Notes.
value1, value2
Expressions, column references or literals to compare as Boolean values.
- Missing or mismatched values generate missing results.
Usage Notes:
Required? | Data Type | Example Value |
---|---|---|
Yes | Function or column reference returning a Boolean value or Boolean literal | myHeight > 2.00 |
Tip: For additional examples, see Common Tasks.
Examples
Example - Logical Functions
AND
, OR
, and NOT
logical functions. - See AND Function.
- See OR Function.
- See NOT Function.
In this example, the dataset contains results from survey data on two questions about customers. The yes/no answers to each question determine if the customer is 1) still active, and 2) interested in a new offering.
Source:
Customer | isActive | isInterested |
---|---|---|
CustA | Y | Y |
CustB | Y | N |
CustC | N | Y |
CustD | N | N |
Transform:
Customers that are both active and interested should receive a phone call:
derive type:single value:AND(isActive, isInterested) as:'phoneCall'
Customers that are either active or interested should receive an email:
derive type:single value:OR(isActive, isInterested) as:'sendEmail'
Customers that are neither active or interested should be dropped from consideration for the offering:
derive type:single value:AND(NOT(isActive),NOT(isInterested) as:'dropCust'
A savvy marketer might decide that if a customer receives a phone call, that customer should not be bothered with an email, as well:
set col:sendEmail value:IF(phoneCall == "TRUE", FALSE, sendEmail)
Results:
Customer | isActive | isInterested | dropCust | sendEmail | phoneCall |
---|---|---|---|---|---|
CustA | Y | Y | FALSE | FALSE | TRUE |
CustB | Y | N | FALSE | TRUE | FALSE |
CustC | N | Y | FALSE | TRUE | FALSE |
CustD | N | N | TRUE | FALSE | FALSE |
This page has no comments.