All docs
/
Getting started
/
Conditional statements

Conditional statements

Control the logic of your workflow

Overview

Conditional statements overview

Conditional statements in Clay help you control the flow of logic of your workflow, allowing you to perform different actions based on conditions. For example, if Company Size > 100, the output will be true.

In Clay, you can use conditional statements in:

  • Conditional runs: Run a certain enrichment based on certain criteria.
  • AI formulas: Transform data, like scoring leads or qualifying opportunities.
  • Conditional Snippets: Embed conditional logic to send outbound messages based on contact criteria.
  • Waterfalls: Maximizing coverage with multiple providers.

Conditional statement structure

Conditional statements have the following structure:

  1. IF (Condition) – Executes a command when the condition is true.
  2. ELSE IF (secondCondition) – Executes a command if the second condition is true (optional).
  3. ELSE – Executes a command when none of the above conditions are true.

Walkthrough

IF Condition

(command to execute if condition is true)

ELSE IF secondCondition

(command to execute if secondCondition is true)

ELSE

(command to execute if no conditions are true)

Best practices

Testing

Prevent unexpected errors with edge cases or missing data.

Examples

  • Empty fields: IF({{company_size}} > 100) THEN "Qualified" ELSE "Not Qualified" , Ensure blank company_size defaults to "Not Qualified".
  • Boundary values: Test company_size = 50 in IF({{company_size}} >= 50) THEN "Medium" ELSE "Small" to avoid misclassification.
  • Unexpected formats: Handle company_size = "unknown" by defaulting to "Not Qualified".

Error handling

Handle missing or invalid data properly.

Examples:

  • Missing fields: In IF({{company_size}} AND {{location}}) THEN "Valid" ELSE "Invalid", return "Invalid" if fields are missing.
  • Clear errors: Use IF({{email}} == "") THEN "Error: Missing Email" ELSE "Valid Email" to flag missing inputs.

Parentheses for clarity

Use parentheses to group conditions clearly, especially when combining multiple logical operators (AND, OR, NOT).

Examples:

  • Unclear: {{size}} > 100 AND {{location}} == "US" OR {{revenue}} > 1M could qualify the wrong leads.
  • Clear: (size > 100 AND location == "US") OR revenue > 1M ensures correct grouping.

Use cases: Lead qualification, CRM updates, or email campaigns where errors could disqualify valid leads or waste resources.

Example conditional statements within Clay

Example #1: Basic email validation

Validate email formats to flag personal email addresses.

Formula

IF (person.email contains @gmail.com OR @yahoo.com)return "Invalid email format"

ELSEreturn "Valid email format"

Test cases

Example #2: Message snippets based on company size

Serve different message snippets based on the company’s size.

Formula

IF (company.size > 500)

return enterprise_message_snippet

ELSE IF (company.size > 50)

return midmarket_message_snippet

ELSE

return small_message_snippet

Test cases

  • Input: company.size = 750Result: enterprise_message_snippet
  • Input: company.size = 100Result: midmarket_message_snippet
  • Input: company.size = 25Result: small_message_snippet
  • Input: company.size = 0Result: small_message_snippetNote: Since this input doesn't satisfy any of the conditions, the final else statement is returned, but we should add some input validation here.

Example #3: Regional discounts based on geography

Apply different discount rates based on the region.

Formula

IF (region == "US")

return "10% Discount"

ELSE IF (region == "EMEA")

return "15% Discount"

ELSE

return "No Discount Available”

Test cases

  • Input: region = "US"Result: 10% Discount
  • Input: region = "EMEA"Result: 15% Discount
  • Input: region = "APAC"Result: No Discount Available

Explore other docs

Getting started

Table versions

Table versioning lets you track structural changes to your Clay tables over time and restore previous configurations when needed.

View article
Getting started

Table alerts

Table alerts automatically monitor your Clay tables and notify you when something needs attention.

View article
Export

Salesforce integration FAQs

Answering common questions about connecting and troubleshooting the Salesforce integration.

View article
Web scraping

Meer integration

Screen phone numbers against national do-not-call registries before initiating outbound calls.

View article
Settings & admin

Best practices for B2B email direct marketing

Conduct effective outbound email outreach whilst also lowering the risk of challenges

View article
Settings & admin

Do Not Contact (DNC) compliance & best practices

Information about DNC compliance and best practices.

View article
Web scraping

BuyerCaddy integration

Enrich company tech stacks, verify technology usage, and more!

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