Skip to main content

Formula Columns

Enterprise

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/case expressions 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>
PartRequiredDescription
{{expression}}YesA Brobench formula expression. Can reference any field selected in the query.
:<type>NoOptional type hint for display formatting (e.g. :number, :date). See below for all types. Defaults to string.
<alias>NoColumn 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.

TypeDisplay BehaviorExample Use
stringPlain text (default)Labels, concatenated strings
booleanCheckbox / true/falseConditional expressions
numberFormatted numberGeneral numeric results
integerWhole number, no decimalsCounts, differences
doubleDecimal numberFinancial or precise calculations
percentNumber displayed as percentageRates, completion ratios
dateDate formatted per user localeDate calculations
datetimeDate + time formatted per user localeTimestamp calculations
durationHuman-readable durationTime elapsed values
bytesHuman-readable byte sizeFile size or data size values

How It Works

  1. 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.
  2. If you use formula columns exclusively (no regular fields), Brobench automatically adds Id to the query so the request is valid.
  3. After records are returned, Brobench evaluates each formula expression for every record, passing the record's fields as variables.
  4. The computed value is added to the record under the alias name and displayed as an extra column in the results grid.

Limitations

info

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 null and evaluates accordingly — which is usually not what you want.
  • SELECT clause only. Formula Columns can only appear in the SELECT clause. They cannot be used in WHERE, 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

SOQLDescription
SELECT Id, CreatedDate, LastModifiedDate, {{diff_date(CreatedDate, LastModifiedDate, 'days')}}:number DateDiff FROM Account LIMIT 100Calculates the number of days between CreatedDate and LastModifiedDate using diff_date.
SELECT Id, Amount, {{Amount * 0.1}}:number Tax FROM Opportunity LIMIT 100Computes 10% tax on the Amount field.
SELECT Id, Name, {{upper(Name)}} UpperName FROM Contact LIMIT 100Converts Name to uppercase using the upper function.
SELECT Id, AnnualRevenue, NumberOfEmployees, {{AnnualRevenue / NumberOfEmployees}}:number RevenuePerEmployee FROM Account WHERE NumberOfEmployees > 0 LIMIT 100Calculates revenue per employee.
SELECT RunTime, {{ RunTime}}:duration RunTimeDuration FROM ApexTestResult where RunTime != null ORDER BY RunTime DESCConverts the runtime number into human readable duration like 5h 3m 3s.