> For the complete documentation index, see [llms.txt](https://docs.coupler.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coupler.io/sources/category/crm/salesforce/best-practices/how-to-use-advanced-filters-in-salesforce.md).

# How to use advanced filters in Salesforce

If you export Salesforce Objects, including standard and custom ones, you can filter records by field values. To do that, use SOQL. Coupler.io adds your filter value to the request as-is, so the filter must use valid SOQL `WHERE` clause syntax.

See the general syntax in the Salesforce [documentation](https://developer.salesforce.com/docs/atlas.en-us.234.0.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_conditionexpression.htm).

Use only `WHERE` clause conditions in the **Advanced Filter** field. Do not use other SOQL operators there, such as `ORDER BY`, `LIMIT`, or `OFFSET`.

### Common examples

#### Filter Accounts by name starting with `Test`

```sql
Name LIKE 'Test%'
```

#### Filter closed Opportunities by close date

```sql
IsClosed = TRUE AND CloseDate > 2021-03-21
```

#### Filter Opportunities by date fields with date literals

See the Salesforce [date literals documentation](https://developer.salesforce.com/docs/atlas.en-us.234.0.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm) for more options.

```sql
CreatedDate = LAST_N_DAYS:180 AND CloseDate = THIS_MONTH
```

#### Filter Opportunities by stage and type

```sql
(StageName != 'Closed Won' AND StageName != 'Prospecting') AND (Type = 'New customer' OR Type = 'Existing customer - upgrade')
```

<figure><img src="/files/yBBBuUjCcbWUmy2TtqNi" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.coupler.io/sources/category/crm/salesforce/best-practices/how-to-use-advanced-filters-in-salesforce.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
