## Key

• This line was added.
• This line was removed.
• Formatting was changed.
Comment: Published by Scroll Versions from space DEV and version next
Excerpt

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.

Functions:

D generate list excerpts
pages AND Function, OR Function, NOT Function

Source:

CustomerisActiveisInterested
CustAYY
CustBYN
CustCNY
CustDNN

Transformation:

Customers that are both active and interested should receive a phone call:

D trans
RawWrangle true 'phoneCall' step derive type:single value:AND(isActive, isInterested) as:'phoneCall' Formula type Single row formula Formula AND(isActive, isInterested) New column name New formula

Customers that are either active or interested should receive an email:

D trans
RawWrangle true 'sendEmail' step derive type:single value:OR(isActive, isInterested) as:'sendEmail' Formula type Single row formula Formula OR(isActive, isInterested) New column name New formula

Customers that are neither active or interested should be dropped from consideration for the offering:

D trans
RawWrangle true 'dropCust' step derive type:single value:AND(NOT(isActive),NOT(isInterested) as:'dropCust' Formula type Single row formula Formula AND(NOT(isActive),NOT(isInterested) New column name 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 step set col:sendEmail value:IF(phoneCall == "TRUE", FALSE, sendEmail) Columns sendEmail Formula IF(phoneCall == "TRUE", FALSE, sendEmail) Edit column with formula

Results:

CustomerisActiveisInteresteddropCustsendEmailphoneCall
CustAYYFALSEFALSETRUE
CustBYNFALSETRUEFALSE
CustCNYFALSETRUEFALSE
CustDNNTRUEFALSEFALSE

D s also
label example_logical_functions