Salesforce Dictionary - Free Salesforce GlossarySalesforce Dictionary
Full Filter Condition/Criteria entry
How-to guide

How to write effective filter conditions

Writing filter conditions is a core admin and developer skill. The same patterns apply across List Views, Reports, Flows, and SOQL; learn them once and reuse everywhere.

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

Writing filter conditions is a core admin and developer skill. The same patterns apply across List Views, Reports, Flows, and SOQL; learn them once and reuse everywhere.

  1. Identify the records to narrow

    Decide which object and what subset matters: Open Opportunities, Closed Cases this month, Leads with no recent activity. The business question drives the filter.

  2. Pick the fields and operators

    Map the business question to fields and operators: Status = Open, ClosedDate = LAST_MONTH, Last_Activity_Date_c older than 90 days. Operators must match the field type.

  3. Build the conditions in the right tool

    For List Views: open the view, click Edit Filters. For Reports: filter pane. For Flows: condition editor. For SOQL: WHERE clause. The syntax differs slightly but the logic is the same.

  4. Combine with AND/OR logic

    Most filters AND conditions together (all must be true). Use OR when any of several conditions counts. Use custom logic with numbered conditions and parentheses for nested logic: (1 AND 2) OR (3 AND 4).

  5. Test with sample data

    Run the filter and confirm it returns the expected records. Edge cases (null values, special characters) often surface here.

  6. Optimize for performance

    Filter on indexed fields when possible (Id, lookup fields, Unique, External Id, fields with custom indexes). Avoid leading wildcards (LIKE %text%); the platform cannot use indexes.

Key options
Equals / Not Equalsremember

Exact value comparison.

Greater Than / Less Thanremember

Numeric and date comparison.

Contains / Does Not Containremember

Substring matching for text fields.

IN list / NOT IN listremember

Multi-value match.

Date literalsremember

TODAY, LAST_WEEK, LAST_N_DAYS, THIS_QUARTER, and so on.

Boolean / picklist filtersremember

Direct value matching for booleans and picklists.

Gotchas
  • Null handling varies by context. Some filters treat null as not equal; others may fail to match expected behavior. Test null cases explicitly.
  • Leading wildcards in text filters disable indexing. Filters like Name LIKE %customer% scan every row; performance degrades on large tables.
  • Date literal semantics differ across tools. TODAY in SOQL is the running user''s timezone; TODAY in formula functions is the org''s timezone. Mismatches cause subtle bugs.
  • Complex custom logic (1 AND 2 OR 3 AND 4) without parentheses can be ambiguous. Use parentheses explicitly to make precedence clear.

See the full Filter Condition/Criteria entry

Filter Condition/Criteria includes the definition, worked example, deep dive, related terms, and a quiz.