Formula Columns
Formula Columns are virtual, in-memory columns you can add to a SOQL query. Brobench evaluates the formula expression locally (not in Salesforce) and displays the result as an extra column in the query results grid.
Formula expressions can use Brobench Formula Functions and other formula constructs to implement custom business logic on top of the data returned from Salesforce.
Purpose
SOQL is a read-only query language — you can filter and sort records, but you cannot compute new values from existing fields. Formula Columns fill that gap. They let you define expressions that are evaluated locally in Brobench after records are fetched, without any changes to your Salesforce org.
Common use cases include:
- Derived metrics — calculate values like revenue per employee, days since last login, or discount percentage from fields already on the record.
- Date arithmetic — compute the difference between two date fields, or check how many days remain until a deadline.
- Data normalization — convert units, reformat strings, or apply business rules to raw field values before reviewing them.
- Conditional flags — use
if/caseexpressions to label records based on field combinations, such as flagging accounts that are overdue or contacts that have never logged in. - Quick analysis — explore and validate data transformations directly in the query results without writing Apex or building a report.
Because formulas run entirely in-memory inside Brobench, they add no load to your Salesforce org and require no deployment.
Syntax
Formula columns are written inline in the SELECT clause using double curly braces:
{{<expression>}}:<type> <alias>
| Part | Required | Description |
|---|---|---|
{{expression}} | Yes | A Brobench formula expression. Can reference any field selected in the query. |
:<type> | No | Optional type hint for display formatting (e.g. :number, :date). See below for all types. Defaults to string. |
<alias> | No | Column name shown in the results grid. Defaults to Formula1, Formula2, etc. |
Example:
SELECT Id, CreatedDate, LastModifiedDate, {{ diff_date(CreatedDate, LastModifiedDate, 'days') }}:number DateDiff
FROM Account
LIMIT 100
Inside the expression, field names from the record are available as variables. Field name matching is case-insensitive (
e.g. CreatedDate and createddate both work).
Result Data Types
The optional :<type> hint tells Brobench how to format and display the column value in the results grid. Without a
type hint the column is treated as string.
| Type | Display Behavior | Example Use |
|---|---|---|
string | Plain text (default) | Labels, concatenated strings |
boolean | Checkbox / true/false | Conditional expressions |
number | Formatted number | General numeric results |
integer | Whole number, no decimals | Counts, differences |
double | Decimal number | Financial or precise calculations |
percent | Number displayed as percentage | Rates, completion ratios |
date | Date formatted per user locale | Date calculations |
datetime | Date + time formatted per user locale | Timestamp calculations |
duration | Human-readable duration | Time elapsed values |
bytes | Human-readable byte size | File size or data size values |
How It Works
- Brobench parses the formula columns out of your SOQL before sending the query to Salesforce. The formula expressions are not sent to Salesforce — only the regular fields are queried.
- If you use formula columns exclusively (no regular fields), Brobench automatically adds
Idto the query so the request is valid. - After records are returned, Brobench evaluates each formula expression for every record, passing the record's fields as variables.
- The computed value is added to the record under the alias name and displayed as an extra column in the results grid.
Limitations
Keep these things in mind when using Formula Columns.
- Select all referenced fields. If a field used inside the formula is not selected in the query, the engine treats
it as
nulland evaluates accordingly — which is usually not what you want. - SELECT clause only. Formula Columns can only appear in the
SELECTclause. They cannot be used inWHERE,HAVING,ORDER BY, or any other clause. - Not supported in Bulk Query. Formula evaluation is skipped when running a bulk query job. Formulas only execute in standard SOQL queries.
- Any number of Formula Columns can be added to a single query.
- Child queries are supported. You can add Formula Columns inside a child (subquery) relationship query.
Examples
| SOQL | Description |
|---|---|
SELECT Id, CreatedDate, LastModifiedDate, {{diff_date(CreatedDate, LastModifiedDate, 'days')}}:number DateDiff FROM Account LIMIT 100 | Calculates the number of days between CreatedDate and LastModifiedDate using diff_date. |
SELECT Id, Amount, {{Amount * 0.1}}:number Tax FROM Opportunity LIMIT 100 | Computes 10% tax on the Amount field. |
SELECT Id, Name, {{upper(Name)}} UpperName FROM Contact LIMIT 100 | Converts Name to uppercase using the upper function. |
SELECT Id, AnnualRevenue, NumberOfEmployees, {{AnnualRevenue / NumberOfEmployees}}:number RevenuePerEmployee FROM Account WHERE NumberOfEmployees > 0 LIMIT 100 | Calculates revenue per employee. |
SELECT RunTime, {{ RunTime}}:duration RunTimeDuration FROM ApexTestResult where RunTime != null ORDER BY RunTime DESC | Converts the runtime number into human readable duration like 5h 3m 3s. |