#SalesforceSummer26 [Tip 22] - Filter SOQL Queries by Calculated Values Without Extra Formula Fields
You need to find records where a calculated value crosses a threshold — projects that are over budget, orders shipped late, invoices with a balance still owing. But there's no field for "budget overrun" or "days late", so you either create a formula field just for the query, or pull back a wide set of records and filter them in Apex afterward.
Summer '26 introduces a pilot that removes that step. You can now use FORMULA() directly inside a SOQL WHERE clause. FORMULA() lets you write a formula-style expression, and the platform evaluates it row by row as part of the filter.
Product Area: SOQL
The shape is simple:
WHERE FORMULA('expression') operator valueFor example, to find active projects that have gone over budget by more than 5,000 (Budget__c and Spent__c are both Currency fields):
SELECT Id, Name, Budget__c, Spent__c FROM Project__c
WHERE Status__c = 'Active' AND FORMULA('Spent__c - Budget__c') > 5000A few things to know about the pilot as it stands. It works only in the WHERE clause, not HAVING. The expression supports addition and subtraction. And expressions can return Double, Integer, Datetime, Date, or Currency values.
Because it's a pilot, it isn't on by default — you request access through your Account Executive or Customer Success Manager, and it's best to try it in a sandbox first.
The Old Way: Filtering in Apex
Before this pilot, the same result meant querying the raw fields and doing the arithmetic yourself in a loop:
// Before FORMULA(): pull the candidate rows, then calculate and filter in code
List<Project__c> overBudget = new List<Project__c>();
for (Project__c p : [
SELECT Id, Name, Budget__c, Spent__c
FROM Project__c
WHERE Status__c = 'Active'
]) {
// Guard against null Currency fields before doing the math
if (p.Budget__c != null && p.Spent__c != null
&& (p.Spent__c - p.Budget__c) > 5000) {
overBudget.add(p);
}
}
// overBudget now holds the same records FORMULA() would have returnedReferences & Useful URLs
For Related Summer '26 Release Note Article – Click Here
Salesforce Developer Blog - Simplify Your SOQL Queries Using SOQL FORMULA() in WHERE