Business Logic and Process Automation · Topic 1 of 7
Formula Fields
Salesforce formula fields: return types, cross-object formulas, blank field handling, common functions, size limits and when a formula is the right tool.
- 4 min
- Formula fields are calculated, read-only and always current.
- Return types: checkbox, currency, date, date/time, number, percent, text, time.
- Cross-object formulas read parent fields, never child records.
What it is
A formula field is a read-only field whose value Salesforce calculates from other fields, functions and operators each time the record is viewed or queried. Nothing is stored and nobody types the value, so it is always current.
Formulas are the first declarative answer when a value can be derived from data already on the record or on its parent records.
How it works
Return types
When you create a formula field, you pick its return type: Checkbox, Currency, Date, Date/Time, Number, Percent, Text or Time. The return type decides how the result is formatted and where it can be used, for example only Number, Currency and Percent formulas can be summed in reports.
Building a formula
The formula editor offers fields, operators and functions. Common function groups:
| Group | Examples | Typical use |
|---|---|---|
| Logical | IF, CASE, AND, OR, NOT, ISBLANK, ISPICKVAL | Choose a value by conditions |
| Text | TEXT, LEFT, CONTAINS, HYPERLINK, IMAGE | Build labels, links and icons |
| Math | ROUND, MAX, MIN, MOD | Calculations |
| Date | TODAY, NOW, DATE, YEAR, MONTH, ADDMONTHS | Ages, due dates, durations |
Picklist fields need ISPICKVAL or TEXT to be compared, because a picklist is not plain text in a formula.
Cross-object formulas
A formula can reference fields on parent records through lookup and master-detail relationships, such as Account.Industry from a Contact. It can span several relationship levels. A formula cannot reference child records; for values from children use a roll-up summary field or automation.
Blank field handling
When a formula references Number, Currency or Percent fields, you choose how blank values in those fields are treated:
| Option | Effect |
|---|---|
| Treat blank fields as zeroes | A blank field counts as 0 in the calculation |
| Treat blank fields as blanks | A blank field stays blank, so the result is usually blank unless the formula handles it, for example with BLANKVALUE |
Pick blanks when an empty result should signal missing data rather than a misleading zero.
Limits and considerations
- A formula has a character limit and a compiled size limit. A large formula can fail to save because of its compiled size even when it has few characters, usually because it references other large formula fields.
- To reduce size, simplify the logic, use CASE instead of nested IFs, or move parts into a separate field.
- Formula fields are read-only and cannot be edited by users or imports.
- Formulas using TODAY or NOW recalculate when viewed, so they cannot be used in roll-up summary fields.
When a formula is the right tool
| Requirement | Tool |
|---|---|
| Show a value derived from this record or its parents | Formula field |
| Total or count child records | Roll-up summary field |
| Store a value that never changes after it is set | Flow that writes to a normal field |
| Block a save when data is wrong | Validation rule |
A worked example: support wants each case to show how many days it has been open, and a red, yellow or green indicator. The builder creates a Number formula TODAY() - DATEVALUE(CreatedDate) for days open, and a Text formula using CASE and IMAGE to show a coloured flag by days-open band.
When a value must stay current automatically and comes only from the record or its parents, a formula field is the expected answer.
How the exam asks about this
- "Show the account's industry on each opportunity." A cross-object formula.
- "Compare a picklist value in a formula." ISPICKVAL or TEXT.
- "The formula will not save because it is too large." Reduce compiled size, for example by simplifying or splitting it.
What to remember for the exam
- Formula fields are calculated, read-only and always current.
- Return types: checkbox, currency, date, date/time, number, percent, text, time.
- Cross-object formulas read parent fields, never child records.
- Blank field handling applies to the number, currency and percent fields a formula references.
- Compiled size, not just character count, limits a formula.
A formula that uses TODAY or NOW cannot be used in a roll-up summary field, because its value changes without the record changing.
Common mistakes
Using a formula to read child records. Use a roll-up summary field or automation.
Comparing a picklist with the equals sign. Use ISPICKVAL or TEXT.
Expecting a formula to keep an old value. Formulas always recalculate; store fixed values with a flow.
Check yourself
Can a formula field on Account show data from its contacts?
No. Formulas can read parent records only; use a roll-up summary or automation for child data.
Which functions compare a picklist value in a formula?
ISPICKVAL, or TEXT to convert the value to text first.
Why might a short formula still fail to save for being too large?
Its compiled size includes referenced formula fields, which can exceed the limit.
Topic 1 of 7 in Business Logic and Process Automation
Test yourself on Business Logic and Process Automation
The full Salesforce Platform App Builder question bank has 648 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Salesforce. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.