All docs
/
Transform
/
Logical operators

Logical operators

Automate decisions with AND, OR, and NOT expressions

Overview

Logical operators overview

A logical operator evaluates one or more conditions and returns a boolean value (true or false). In Clay, these operators let you combine and modify conditions to build complex logical expressions.

The three main types of logical operators are:

  • AND (&&): Returns true only if all conditions are true
  • OR (||): Returns true if at least one condition is true
  • NOT (!): Reverses a boolean value

When do you use logical operators?

Logical operators are commonly used in several contexts within Clay.

AI Formula Columns: Create complex conditions for data transformation with multiple criteria.

Conditional Runs: Control when enrichments should execute by definingspecific trigger conditions.

SOQL Queries: Filter Salesforce objects based on multiple criteria.

Best practices

When using logical operators, follow these guidelines:

  • Use parentheses to clearly group conditions and control evaluation order
  • Test edge cases to ensure correct behavior

AND statements

Syntax

condition1 && condition2

Overview

  • Returns true if both conditions are true.
  • Returns false if either condition is false.
  • In formulas, represented as && .

Example cases

Example 1: true && true → true

Example 2: true && false → false

Example 3: false && false → false

Use case example

Scenario: You want to qualify a lead if they have more than 500 employees and are located in the US.

Formula: {{employee_count}} > 500 && {{location}} == "US"

Logic: Returns true if the lead has more than 500 employees and is in the US.

OR statements

Syntax

condition1 || condition2

Overview

Returns true if at least one condition is true.

Returns false only if both conditions are false.

In formulas, represented as || .

Example cases

Example 1: true || true → true

Example 2: true || false → true

Example 3: false || false → false

Use case example

Scenario: You want to qualify a lead if they have more than 500 employees or are located in the US.

Formula: {{employee_count}} > 500 || {{location}} == "US"

Logic: Returns true if the lead meets either condition.

NOT Statements

Syntax

!condition1

Overview

Returns the opposite of the condition:

  • true becomes false.
  • false becomes true.

Often used to exclude specific conditions.

In formulas, represented as ! .

Example cases

Example 1: !true → false

Example 2: !false → true

Use Case Example

Scenario: You want to exclude leads marked as competitors from being qualified.

Formula: !{{competitor}}

Logic: Returns true if the lead is not a competitor.

Combining AND, OR, and NOT

Syntax

(condition1 && condition2) || !condition3

Use case example

Scenario: You want to qualify a lead if either of the following is true:

  1. The lead has more than 500 employees and is based in the US.
  2. The lead is not a competitor.*

Formula: ({{employee_count}} > 500 && {{location}} == "US") || !{{competitor}}

Logic Breakdown:

  • Part 1: {{employee_count}} > 500 && {{location}} == "US" → Returns true if the lead has more than 500 employees and is located in the US.
  • Part 2: !{{competitor}} → Returns true if the lead is not marked as a competitor.
  • The entire formula returns true if either part is true.

‍

Explore other docs

Settings & admin

Set up SCIM provisioning in Clay

Keep your Clay workspace membership and roles in sync with your identity provider.

View article
Gen AI

Scheduled tasks

Set a task to run on its own — daily, on weekdays, weekly, or monthly — so recurring go-to-market work happens without you starting it.

View article
Gen AI

Knowledge Hub

Keep one reviewable record of your business in Clay — what you sell, who you sell to, and what signals matter — that Clay drafts and you edit.

View article
Enrich

Upriver integration

Map the sponsorships, products, and audiences behind any brand.

View article
Settings & admin

Beta program

Get early access to new Clay features through the Beta program, and see how to join, leave, and share feedback.

View article
Enrich

G2 integration

Find software products on G2, pull their ratings, features, reviews, and competitors, and build lists of companies researching the categories you compete in.

View article
Gen AI

Clay (global agent)

Chat with Clay, our global agent, to build and run go-to-market plays: it plans, analyzes, and carries out work across many of Clay's surfaces.

View article

Other popular resources

Experts

Find a Clay Expert

Explore our network of Clay experts and agencies.

View experts
Community

Join our slack community

Find help in our slack community, and support channels.

Go to slack
Cohorts

Join a cohort, learn Clay fast!

The faster way to master Clay. Sign in if you're enrolled in a cohort (current or past) or apply!

Learn more about cohorts
Talents

Hire GTME Talent

Find and connect with GTM talent who've demonstrated expertise in building advanced workflows

Explore GTME talents