This example demonstrate the AND
, OR
, and NOT
logical functions.
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 |
Transformation:
Customers that are both active and interested should receive a phone call:
D trans |
---|
RawWrangle | true |
---|
p03Value | 'phoneCall' |
---|
Type | step |
---|
WrangleText | derive type:single value:AND(isActive, isInterested) as:'phoneCall' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | AND(isActive, isInterested) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
Customers that are either active or interested should receive an email:
D trans |
---|
RawWrangle | true |
---|
p03Value | 'sendEmail' |
---|
Type | step |
---|
WrangleText | derive type:single value:OR(isActive, isInterested) as:'sendEmail' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | OR(isActive, isInterested) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
Customers that are neither active or interested should be dropped from consideration for the offering:
D trans |
---|
RawWrangle | true |
---|
p03Value | 'dropCust' |
---|
Type | step |
---|
WrangleText | derive type:single value:AND(NOT(isActive),NOT(isInterested) as:'dropCust' |
---|
p01Name | Formula type |
---|
p01Value | Single row formula |
---|
p02Name | Formula |
---|
p02Value | AND(NOT(isActive),NOT(isInterested) |
---|
p03Name | New column name |
---|
SearchTerm | New formula |
---|
|
A savvy marketer might decide that if a customer receives a phone call, that customer should not be bothered with an email, as well:
D trans |
---|
RawWrangle | true |
---|
Type | step |
---|
WrangleText | set col:sendEmail value:IF(phoneCall == "TRUE", FALSE, sendEmail) |
---|
p01Name | Columns |
---|
p01Value | sendEmail |
---|
p02Name | Formula |
---|
p02Value | IF(phoneCall == "TRUE", FALSE, sendEmail) |
---|
SearchTerm | Edit column with formula |
---|
|
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 |