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.
Arithmetic formulas in a SOQL WHERE clause is a beta service that is subject to the Beta Services Terms at Agreements - Salesforce.com or a written Unified Pilot Agreement if executed by Customer, and applicable terms in the Product Terms Directory. Use of this beta service is at the Customer’s sole discretion.
op— The arithmetic operator. Supported values:+or-.comparisonOperator— A standard comparison operator such as>,<,=,>=,<=, or!=.literalValue— The value to compare the result against.
Both fields in the FORMULA() expression must use a supported data type. The supported data types are:
- Double/Decimal
- Integer
- DateTime
- Date
- Currency
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.
DATEandDATETIMEfields cannot be mixed in the same expression.- Only
+and-arithmetic operators are supported. FORMULA()inWHEREclauses does not support any other formula engine capabilities.
This example filters opportunities where the difference between Amount and ExpectedRevenue exceeds 100.
This example filters records where CloseDate is more than 10 days after CreatedDate.