Calculated Fields Overview
Page calculated fields display computed values on Business Central pages without storing data in the database. This page introduces the concept and capabilities.
What Are Calculated Fields
Calculated fields are:
- Displayed on pages like regular fields
- Computed from expressions when the page loads
- Not stored in the database
- Updated when the page refreshes
Common misconceptions
Calculated fields are not FlowFields. Aggregations — Sum, Average, Min, Max, Count — are FlowField features. A calculated field is an expression: use it to subtract one field from another, concatenate text, or apply conditional logic. To total values across related records, use a FlowField instead.
They are not defined on tables. A calculated field is "not really a field" — it exists on a page. Do not look for it in table design. Create one from Tasks > Page Calculated Fields in the main menu.
They are page-level by design. SOD does not support general expression-based calculated fields at the table level. A calculated field must be recalculated every time it is accessed, and Business Central offers no clean mechanism for recalculation-on-access at the table level — only on pages. That is why SOD implements expression-based calculations as page (and report) calculated fields. This is a current limitation, not a defect.
If you need a reusable, table-level computed value — available across several pages, reports and APIs without recreating it each time — a FlowField may be the answer. FlowFields are table-level calculated fields, calculated on demand, supporting Count, Sum, Average, Min, Max, Lookup and Exist over a related table. They only work when the calculation can be expressed as one of those operations; they are not general-purpose expression fields. Create one via Create new fields on existing tables with Type = FlowField. See FlowFields.
Calculated vs Stored Fields
| Aspect | Calculated Field | Stored Field |
|---|---|---|
| Storage | None | Database |
| Updates | On page load | On data change |
| Performance | Computed each view | Pre-stored |
| Use case | Display-only | Editable |
| Flexibility | Expression-based | Fixed value |
What You Can Calculate
Arithmetic Operations
Combine numeric fields:
Rec."Quantity" * Rec."Unit Price"- Line amountRec."Amount" * 0.1- 10% of amountRec."Total" - Rec."Discount"- Net amount
Text Operations
Manipulate text fields:
- Concatenate names
- Format values
- Build display strings
Conditional Logic
Display different values based on conditions:
- Status indicators
- Warning messages
- Categorizations
Conditional logic is written with the ternary operator:
<if expression> ? <true expression> : <false expression>
The expression verifier does not understand the ternary operator. It will flag a ternary expression as invalid. This is expected — if the expression is otherwise correct it still compiles and works at runtime on BC25+, and it publishes successfully despite the warning.
Microsoft's documentation on the AL ternary operator is in the Business Central release plan under "use ternary operator when coding AL language".
Referencing FlowFields
FlowFields can be used inside a calculated field expression. Reference them with the Rec. prefix:
Rec.NameOfFlowField
For example, a Sum FlowField holding a decimal total can be subtracted from another decimal field in the same expression. This corrects a common misconception that SOD does not recognize FlowFields in calculated fields — it does, through Rec..
Date Calculations
Work with dates:
- Days between dates
- Age calculations
- Due date indicators
Common Use Cases
Display Formatted Names
Rec."First Name" + ' ' + Rec."Last Name"
Show Calculated Amounts
Rec."Quantity" * Rec."Unit Price" * (1 - Rec."Discount %" / 100)
Status Indicators
Rec."Amount" > 1000 ? 'High Value' : 'Standard'
Days Overdue
Rec."Due Date" < Today() ? Today() - Rec."Due Date" : 0
Accessing Calculated Fields
From Main Menu
- Open Tasks > Page Calculated Fields
- Opens the Calculated Fields list
From Page Customization
- Open Inspect > Pages
- Select a page
- Click Customize Page
- Click Calculated Fields action
The Calculated Fields Page
Shows all defined calculated fields:
Columns
| Column | Description |
|---|---|
| Page No. | Target page |
| Page Name | Page name |
| Name | Calculated field name |
| Type | Result type (Decimal, Text, Boolean, Date) |
| Field Caption | Display label |
| Expression | Calculation formula |
| Placement Type | Position on page |
| Anchor Field | Reference for placement |
| Drill Down Page | Optional page to open on click |
Calculated Field Types
Decimal
For numeric calculations:
- Amounts
- Percentages
- Measurements
Integer
For whole-number results:
- Counts
- IDs
- Indexes
Text
For text results:
- Formatted values
- Concatenations
- Status text
- Messages
Boolean
For true/false results:
- Indicators
- Conditions
- Flags
Date
For date calculations:
- Computed dates
- Date differences
Duration
For elapsed-time results.
Types accepted but not evaluated. Two types are selectable but not supported by the expression verifier:
- Boolean — use Text plus a ternary instead:
Rec."Active" ? 'Yes' : 'No'- Duration — selecting it produces a warning that the type is not supported for calculations. Support for Duration in calculated fields is a planned future release, not a current capability.
Placement on Pages
Calculated fields are placed like regular fields:
| Placement Type | Description |
|---|---|
| AddFirst | First in a group |
| AddLast | Last in a group |
| AddBefore | Before specific field |
| AddAfter | After specific field |
See Anchors and Placement for details.
An invalid anchor blocks publishing. A calculated field fails to publish if its Anchor Field references a field that does not exist on the target page. Verify the anchor name against the actual page before publishing, and use Get Source Code from selected error on a publish error to find which anchor reference is wrong.
Drill-Down Support
Calculated fields can link to other pages:
- Set the Drill Down Page property
- When users click the field, the target page opens
- Useful for navigating to related information
Example
A calculated "Order Count" field could drill down to the Sales Orders list.
Click-through to a related record's card
To make a field open a related record's card — clicking through to the Customer Card, for instance — a Lookup FlowField with the target card set as its Drilldown page is the supported approach. That is a different mechanism from a calculated field's Drill Down Page property.
The prerequisite is that a lookup field for the related record (a Customer No. field, say) already exists on the source record. See Field Settings.
Verification and Compilation
SOD validates expressions:
Expression Verification
- Checks syntax
- Validates field references
- Reports errors before publishing
Two caveats:
- Ternary expressions fail verification even when they are correct. The verifier does not understand the operator; the expression still compiles and runs.
- Verification passing does not guarantee publishing. Verification checks the expression, not every name involved. A known cause of a post-verification publish failure is a field or calculated field name that starts with a number — see Create New Fields. In the AL error output,
Syntax error,AL0104andAL0124point at an invalid identifier rather than a logic problem in the expression.
Runtime Compilation
- Expressions compile when extension publishes
- Runtime errors may still occur
- Test thoroughly with real data
Benefits
No Database Storage
- No schema changes required
- No data migration concerns
- Flexible changes
Dynamic Values
- Always current
- Based on live data
- No sync issues
User Experience
- Rich display information
- Derived data visible at a glance
- Interactive (drill-down)
Limitations
Display Only
- Users cannot edit calculated fields
- Values reset on page reload
- No audit trail
- A calculated field cannot persist anything. A field showing the current date or time reflects the moment the page is viewed — not a fixed timestamp of when the record was created or changed. It cannot record an event.
Not a real field
A calculated field is not a stored field, which has three consequences:
- It cannot be the source of a Field Transfer to another table.
- It cannot be aggregated by a FlowField. You cannot Sum a calculated field across records.
- You cannot create a stored field with an expression. Creating a real field through "Create new fields on existing tables" offers no expression option. Hougaard is investigating a feature that may enable this; watch the newsletter for updates.
Sorting and Analysis mode
- Calculated fields cannot sort a standard list view. The calculation runs after the records have been sorted, so the sort cannot act on the calculated values.
- Workaround: switch the list into Analysis Mode, where sorting on the column is possible.
- But note: in Analysis mode the calculations are not triggered, so calculated field values do not appear or update there. This is Business Central behaviour — the reason is unknown, it has been raised with Microsoft, and it cannot be fixed in SOD.
No conditional styling
StyleExpr — conditional font or colour formatting, showing a value in red when a condition is true — cannot be defined through a calculated field expression. This is out of scope for calculated fields, and colour/label styling generally is not available in SOD. See Limitations.
No ToolTip
Page Calculated Fields do not currently offer a ToolTip property. Regular fields support tooltips through Field Settings; calculated fields do not. This is an open feature request, not current behaviour.
Bound to one source table
A calculated field's expression can only reference Rec."..." fields from the source table of the page it lives on.
Consequently, a calculated field created on one page cannot be transferred to or reused on a page based on a different table. The same field references simply do not exist there, and no workaround makes them available. To get the same value on the second page, create a new calculated field there using fields from that page's source table.
Not available in Features
Calculated fields are not currently supported inside Features. Totalling several decimal fields defined within a feature, or deriving a value such as cost-per-serving from other feature fields, is not possible today. There is no location — item card, inside a recipe, or elsewhere in a feature — to define an inline calculated field for feature use.
This is on the roadmap with no ETA.
Unsupported workaround: deploy the feature first, then use the standard page calculated field option against the deployed feature's page. This is not officially supported and is entirely at your own risk. It may work, but it is discouraged — if you try it, do so in a sandbox you can reset, never in production.
Related: writing custom calculations directly to a field is not supported outside Document Template Features, and trigger code support is planned for the next major SOD upgrade.
Performance
- Complex expressions may slow page loading
- Many calculated fields compound impact
- Consider simpler expressions or FlowFields for heavy calculations
Expression Constraints
- Can only reference fields on the page's source table
- Limited function library
- No external API calls