Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Operator entry
How-to guide

How to choose the right operator for a formula or query

Choosing the right operator means matching the data type, the context (formula vs SOQL vs Flow), and the semantics you actually need. Walk through the decision systematically.

By Dipojjal Chakrabarti · Founder & Editor, Salesforce DictionaryLast updated May 21, 2026

Choosing the right operator means matching the data type, the context (formula vs SOQL vs Flow), and the semantics you actually need. Walk through the decision systematically.

  1. Identify the context

    Formula field, validation rule, workflow rule, Flow condition, SOQL query, report filter, or SAQL? Each context has its own operator vocabulary; pick the right one before writing the expression.

  2. Identify the data type

    Number, text, date, datetime, picklist, multi-select picklist, ID, boolean? Operators that work for numbers (<, >) often do not work for text. Multi-select picklists need INCLUDES, not =.

  3. Pick the operator that matches semantics

    Are you comparing equality, ordering, set membership, pattern, or blankness? Equality uses =, ordering uses < or >, set membership uses IN, pattern uses LIKE, blankness uses ISBLANK.

  4. Wrap with parentheses for precedence

    Mixed AND/OR conditions are ambiguous without parentheses. Always group explicitly. AND(OR(a, b), c) reads correctly; a OR b AND c is fragile.

  5. Test against edge cases

    Null values, empty strings, dates at month boundaries, multi-select picklists with no selections, and negative numbers all expose operator bugs. Build test scenarios that hit each.

Key options
Equality (=, !=)remember

Compare two values for exact match. Default operator for most string and ID comparisons.

Ordering (<, >, <=, >=)remember

Compare numeric or date values. Does not work for text in most contexts.

Pattern (LIKE, CONTAINS)remember

Match a substring or wildcard pattern. LIKE in SOQL; CONTAINS in formulas.

Set membership (IN, INCLUDES)remember

Check if a value is in a list. IN for single-value fields; INCLUDES for multi-select picklists.

Logical (AND, OR, NOT)remember

Combine conditions. Use parentheses to make precedence explicit.

Blankness (ISBLANK, ISNULL)remember

Test for empty values. ISBLANK is the safer choice for text fields.

Gotchas
  • Equals vs assignment is a classic bug. In formulas and SOQL, = is comparison. In Apex, = is assignment and == is comparison. Mixing them up causes silent errors.
  • Multi-select picklists do not compare with =. Use INCLUDES and EXCLUDES, even though Salesforce sometimes lets = silently pass and return nothing.
  • LIKE in SOQL is case-insensitive but column collation can change behavior. Test pattern queries in the actual context the production code uses.
  • Operator precedence in formulas is not the same as in SQL or Apex. AND binds tighter than OR in formulas; in some contexts (Flow conditions), the engine evaluates conditions in source order. When in doubt, parenthesize.

See the full Operator entry

Operator includes the definition, worked example, deep dive, related terms, and a quiz.