---
schema_version: "1"
id: 18107b051720d56dd7c9971115124983e739f3fefdf6e84998983e09487cdacf
title: FORMULA() (Beta)
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-soql-sosl/guides/soql-sosl/sforce-api-calls-soql-select-formula.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-soql-sosl/guide/sforce-api-calls-soql-select-formula.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: fd1ebbb333d89d32ee6823bbf2f454001284f734240d48a81ba535aeba3b33a2
products:
  - SOQL and SOSL Reference
  - Platform Developer Content
---

# FORMULA() (Beta)

Use the `FORMULA()` function in a `WHERE` clause to filter records based on arithmetic operations on two field values. The `FORMULA()` function is not supported in the `SELECT` clause.

**important:** Arithmetic formulas in a SOQL WHERE clause is a beta service that is subject to the Beta Services Terms at [Agreements - Salesforce.com](https://www.salesforce.com/company/legal/agreements/) or a written Unified Pilot Agreement if executed by Customer, and applicable terms in the [Product Terms Directory](https://ptd.salesforce.com/). Use of this beta service is at the Customer's sole discretion.

## Syntax

```soql
WHERE FORMULA('fieldName op fieldName') comparisonOperator literalValue
```

- `op` — The arithmetic operator. Supported values: `+` or `-`.
- `comparisonOperator` — A standard comparison operator such as `>`, `<`, `=`, `>=`, `<=`, or `!=`.
- `literalValue` — The value to compare the result against.

## Supported Data Types

Both fields in the `FORMULA()` expression must use a supported data type. The supported data types are:

- Double/Decimal
- Integer
- DateTime
- Date
- Currency

## Restrictions

The following restrictions apply when using the `FORMULA()` function in a `WHERE` clause:

- If the left-hand side is not a date type, the right-hand side cannot be a date type.
- `DATE` and `DATETIME` fields cannot be mixed in the same expression.
- Only `+` and `-` arithmetic operators are supported.
- `FORMULA()` in `WHERE` clauses does not support any other formula engine capabilities.

## Examples

```soql
SELECT Id FROM Opportunity WHERE FORMULA('Amount - ExpectedRevenue') > 100
```

This example filters opportunities where the difference between `Amount` and `ExpectedRevenue` exceeds 100.

```soql
SELECT Id FROM Opportunity WHERE FORMULA('CloseDate - CreatedDate') > 10
```

This example filters records where `CloseDate` is more than 10 days after `CreatedDate`.
