Appearance
XBRL Formula
The XBRL Formula specification defines a standardised mechanism for creating validation rules within taxonomies using XPath 2.0 expressions.
Why Formulas?
The calculation linkbase only handles simple addition/subtraction. Formulas handle everything else:
- Complex mathematical relationships
- Cross-checking between different parts of a report
- Mandatory field checks
- Date comparisons
- Conditional logic
Three Types of Assertions
1. Value Assertions (Most Common)
A boolean expression evaluated against matched facts:
test="$Assets = $Equity + $Liabilities"Passes if true, fails if false.
2. Existence Assertions
Verify that required data exists:
evaluation-count="count($Revenue) >= 1"Ensures "Revenue" is reported at least once.
3. Consistency Assertions
Compare a calculated value against a reported value within a tolerance:
- Used for cross-checking derived data
Anatomy of a Formula Rule
Formula Rule
├── Rule Name / ID (generates error codes on failure)
├── Test Expression (XPath 2.0 logic)
├── Variables (inputs selecting specific facts)
│ └── Filters (refine which facts each variable selects)
├── Preconditions (optional: when to run the rule)
├── Severity (ERROR or WARNING)
└── Messages (what to display on pass/fail)Variable Filters
| Filter Type | Purpose |
|---|---|
| Concept Filter | Select facts by concept name |
| Explicit Dimension Filter | Constrain to specific dimensional members |
| Typed Dimension Filter | Work with typed dimension values |
| Period Filter | Match across time periods |
| Concept-Relation Filter | Leverage taxonomy hierarchies |
| Aspect-Cover Filter | Override implicit filtering |
Implicit Filtering
A powerful built-in mechanism that automatically groups facts sharing uncovered aspects (period, unit, entity, dimensions). This means a single rule can apply across multiple scenarios without explicit enumeration.
Example: A rule $Assets = $Equity + $Liabilities will automatically apply to every combination of entity, period, and dimensions where all three concepts are reported.
Example from the LEI Taxonomy
The LEI taxonomy includes formula assertions that validate Legal Entity Identifiers:
xml
<va:valueAssertion
id="lei-fact-checksum"
test="lei-fn:validate-checksum( $v )"
implicitFiltering="true"
aspectModel="dimensional">This validates that every reported LEI fact has a valid checksum. If it fails:
"The value 'ABC123...' is not a valid Legal Entity Identifier (invalid checksum)"Severity Levels
- ERROR (default) -- the report is invalid
- WARNING -- potential issue, but the report may still be valid
Common Validation Patterns
| Pattern | Example |
|---|---|
| Aggregation | Totals = sum of components |
| Mandatory checks | Certain concepts must be reported |
| Date comparisons | End date must be after start date |
| Roll-forward | Opening balance + changes = closing balance |
| Cross-period | Instant values match duration endpoints |
| Format validation | Values match expected patterns (like LEI checksum) |
Messages
Rules can include localised messages with dynamic content using XPath:
xml
<msg:message xml:lang="en">
The value '{ $v }' is not a valid Legal Entity Identifier
</msg:message>The { $v } is replaced with the actual value at runtime.