Add a Formula Field
A Formula field calculates its value from other fields, so nobody has to type it or keep it in sync. Use it for values such as a full name built from first and last names, a total of several fees, or the number of days until a permit expires.
Prerequisites
- Your role has Configure Entity on the entity, and the entity is not locked.
- The fields the formula uses already exist on the entity, or on an entity it is linked to by an association field.
Steps
Open the entity's Configure page
Go to System Tools then Entities, click the ⋯ menu on the entity's row, and choose Configure.
Click + on the section
In the Sections pane, click the + button (tooltip Add Field) on the section the field belongs in.
Pick Formula
On the Custom tab, choose Formula under All. The panel shows the Formula Builder.
Name the field
Type the Field Label for the result, such as Total Fees or Days Until Expiration.
Insert a function
In the Function Code editor, click Formula to browse the function list, or start typing a function name in capital letters (for example IF) to see matching functions. Each entry shows a description, its syntax, and an example. Pick one to insert it.
Insert fields
Click Fields, or type an opening brace, to pick a field from this entity. Fields of linked entities are listed too. The field is inserted as a tag in the formula.
Finish the expression and click Add
Combine functions, fields, numbers, and quoted text, then click Add.
How formula values are filled in
A formula is calculated by the platform after a record is saved, not while someone is typing. Formula fields cannot be placed on a form; the form builder shows them as calculated by a formula. They appear on grids, detail pages, and dashboards like any other field.
Function library
| Category | Functions |
|---|---|
| Conditional | IF, SWITCH |
| Mathematical | SUM, COUNT, AVG, MIN, MAX, ROUND, ABS, DIVIDE, MULTIPLY, MINUS, MOD, POWER, SQRT, LOG |
| Logical | AND, OR, NOT, XOR, EXACT |
| Text | CONCATENATE, UPPER, LOWER, LEN, IN, LEFT, RIGHT, MID, TRIM, REPLACE, REPT, SEARCH, SUBSTITUTE, TEXT, STR, VALUE |
| Date & Time | TODAY, NOW, DATE, DATEVALUE, DATEADD, ADD_DAYS, SUBTRACT_DAYS, DATEDIFF, DAYS, WORKDAY, WORKDAYS, MONTH, YEAR, DAY, HOUR, MINUTE, SECOND, HOURS_DIFF, MINUTES_DIFF, ADD_MINUTES, SUBTRACT_MINUTES, FORMAT_DATE, IOSWEEKNUM, WEEKNUM |
| Array | APPEND, EXTEND, REMOVE |
| Constants | PI, TRUE, FALSE |
A few common patterns, shown with field names in braces:
| Goal | Formula |
|---|---|
| Join two text fields | CONCATENATE({First Name}, " ", {Last Name}) |
| Add up fees | SUM({Plan Review Fee}, {Permit Fee}, {Technology Fee}) |
| Days between two dates | DATEDIFF({Expiration Date}, TODAY(), "days") |
| A due date 30 days out | ADD_DAYS({Application Date}, 30) |
| A label based on a value | IF({Estimated Cost} > 100000, "Major", "Minor") |
Example
A Building Permit entity with three fee fields.
| Setting | Value |
|---|---|
| Field Label | Total Fees |
| Function Code | SUM({Plan Review Fee}, {Permit Fee}, {Technology Fee}) |
| Section | Fees |
After a permit is saved, Total Fees shows the sum. Add it as a grid column or a dashboard Number widget.
Common mistakes
- Expecting the value to update while the form is open. The result appears after the record is saved.
- Trying to add a formula field to a form. It is calculated, so it cannot be entered on a form.
- Typing a field name instead of inserting it. Use Fields or the brace shortcut so the reference is a real field tag.
- Comparing dates as text. Use the Date & Time functions with Date fields.
- Using a formula for values that come from outside the record. Use an automation instead. See the Automation Builder overview.