740 likes | 932 Views
16 th XBRL International Conference Demystifying XBRL Formulas December 5, 2007 Herm Fischer. Overview. Why, who needs formulas for what? Historical perspectives Process flow of formulas Formula Linkbase Contents Formula processing Features by use case example DTS discovery Functions
E N D
16th XBRL International Conference Demystifying XBRL Formulas December 5, 2007 Herm Fischer
Overview • Why, who needs formulas for what? • Historical perspectives • Process flow of formulas • Formula Linkbase • Contents • Formula processing • Features by use case example • DTS discovery • Functions • Built-in • End-user • Roadmap
Why formulas Calculation Linkbase is Enough • Roll-ups validates item sums • Addition within equal context • Period, entity, dimension are equal Calculation Linkbase Can’t Do • Cross context • Movement (start + changes = end) • Dimensions • Business rules
Historical Perspectives • 2002 - FDIC contract motivates solutions • Conceptual prototype based on XSL • Excel-like, implicit matching (now in use) • “ - Rule base Requirements IWD • 2003 - XPath syntax chosen • “ - Functions spec drafted. • 2004 - Formula drafts, some implementations • 2006 - Alternative approach with XQuery • 2007 Jan- Issued Formula PWD • Feb, Mar - Survey of users, feedback • June – PWD update based on survey feedback • Dec (late) – PWD-2
Original motivationEffective exchange of data • Information producer • Validate data types and values • Consistency and quality checks • Information consumer • (ditto) • Completeness checks • Augment received data with calculated values • Augment received data with annotations
XBRL without formulas • Calculation linkbase • Well behaved roll-ups of compatible numerical values • (Proposed) Aggregation of dimensional values • Calculation linkbase can’t do • Cross-context (ending bal = starting bal + changes) • Cross-unit (dollars = price per share X nbr shares) • Dimensional aggregation (all = red wine + white wine) • Missing items checks • Threshold and limits (sum amounts ± €5)
Process flow of formulas Formula LB* Output inst.computedfact items Input inst.DTS contextsunitsfact items FormulaProcessor *Formula LB is part of DTS
Input instance processing • Instance provides producer’s taxonomy, facts, and producer’s formulas • Consumer may have their own formulas, their own resulting items taxonomy • Formula processor ‘fires’ formulas that match to input fact items • Formula processor produces output instance with result fact items
Formula linkbase contents Formula LB* formula arc precondition Parameter(select expr.) variable filter customfunction loc label ref. Input inst.DTS contextsunitsfact items Output inst.computedfact items FormulaProcessor *Formula LB is part of DTS
Formula processing Formula LB* • For each/any formula (unordered) • Evaluate parameters (if any) • Filter/bind variables in their order • Nested variable iteration • Test precondition (if any) • Evaluate value • Produce output fact FormulaProcessor Input inst.DTS contextsunitsfact items Output inst.computedfact items *Formula LB is part of DTS
Assets sum test, pseudo code • Test that “assets = liabilities + equity” • Input instance has assets, liabilities, and equity • Output boolean test result, true or false
Assets sum test, flow • Processing flow Formula LB* FormulaProcessor Output inst.Test resultboolean Input inst.DTS assets, liab, equity *Formula LB is part of DTS
Assets sum test, instances • Instance document input has values to test • Output is the boolean result of testing the sum units match same context
Variation: Compute the assets • Prior example tested assets = equity + liabilities • 3 inputs (assets, equity, liabilities) • 1 output (boolean test) • Now no input sum - compute sum as the result • 2 inputs (equity, liabilities) • 1 output (monetary assets)
Compute assets, taxonomy • Taxonomy has monetary concepts for assets, liabilities, equity • Here output is the assets concept (vs. boolean) Last example:
Compute assets, instances • Instance document input has values to add • Output is the monetary result of adding the sum units match same context
Formula linkbase resources • Parameter • Function declaration • Formula • Variables • Filters • Precondition • Generic label • Generic reference
Parameter resources • Provide input parameters to formula processor • From external source (invocation of processor) • Or from XPath expression in Parameter • May be required (or optional) • Evaluated before any formula variable (Parameter resources can have arcs to labels & references)
Function declaration resources • Declare functions usable in XPath expressions • May be user-supplied • May be built-in to formula processor • May relate to formula registry • Function input parameters • Order, data type • Function name • Function output data type (Function declarations can have arcs to labels & references)
Formula resource • Value expression • Concept (either fact variable name or arc to loc) • Context & Unit (where needed) • Fact variable reference (copy from fact variable) • Override facets by xml (e.g., period, measure) • Arcs to variables, precondition (Formula resources can have arcs to labels & references)
Variable resources • Fact variables • Bind to input instance fact items/tuples • Arcs to filters constrain which input facts to bind to • Iterates through filtered input facts or returns sequence • General variables • An XPath expression (not to input fact nodes) • Produce sequence or individual atomic results • No arcs to filters • Order in formula by dependency of variables & filters (Variables may have arcs to labels & references)
Filter resources • Specify a facet to use as fact predicate • Have arc(s) from fact variable(s) • Available filter facets • Concept, Dimension, Entity, Period, Tuple, Unit, Value, and General (XPath expression) • Implicit filtering • Automates matching non-explicitly filtered facets • Variable-set • PWD 2 feature facilitating filter grouping (Filters can have arcs to labels & references)
Precondition resource • Provides an XPath expression to test • Runs after parameters and variables are bound • Arc-connected from formula resource(s) • PWD 2 adds variable-set precondition feature (Preconditions can have arcs to labels & references)
Generic label resources • Annotates descriptive text on any • Resource (e.g., any in formula LB) • Element in xsd (e.g., concept, arc type, etc.) • Arc connected (from resource or element) • Unconstrained contents
Generic reference resources • Provides link:part’s to any • Resource (e.g., any in formula LB) • Element in xsd (e.g., concept, arc type, etc.) • Arc connected (from resource or element)
Fact variable filters • Concept filter • Dimension filter • Entity filter • General filter • Period filter • Tuple filter • Unit filter • Value filter • PWD-2 additions: Boolean, Match, Relative
Concept filter • Filter by name of concept • Filter by facet of concept • Balance • Data type • Substitution group • Period type • Custom attribute
Concept name filter • Sum test uses a concept filter on each variable <cf:conceptName xlink:type="resource" xlink:label="filter_assets“> <cf:name strict=“true”> <cf:qname>eg:assets</cf:qname> </cf:name> </cf:conceptName>
Period filter • Match completely another variable’s period • Match date date/time of: • periodStart • periodEnd • periodInstant • periodInstantDuration • Matching by an XPath 2 expression
PeriodStart filterMovement example • Ending balance = beginning balance + changes • Inputs have cross-context matching • Starting balance’s date matches duration’s start • Ending balance’s date comes from duration’s end
Period filter • PeriodStart filter matches change’s duration start dateto beginningBalance’s instant date <pf:periodStart date=“xfi:period-instant( xfi:period($beginningBalance))” />
Aspects • Location (tuple nesting) (both tuple & item) • Concept (namespace & name) ( “ ) • Entity identifier (item only) • Period ( “ ) • Segment (complete, nonXDT, or dimension) ( “ ) • Scenario ( “ ) ( “ ) • Unit (numeric items only)
Implicit filter, beginning balance Carried forward Implicit Search Criteria Default Implicit Search Criteria Explicit Criteria from Variable Definition Search Criteria for Variable = +
Implicit filter, changes Beginning Balance Implicit Search Criteria Explicit Criteria from Variable Definition Carried forward Implicit Search Criteria Search Criteria for Variable = +
Implicit scenario & segment issues • Dimensional implicit filters • Dimension contents are matched with d-equals • Remaining contents matched with s-equals • Non-dimensional implicit filters • Contents matched with s-equals
Result concept taken from input fact • Result concepttakes conceptof a boundvariable insteadof loc & arc
Movement example • Try it, examine it, execute it online: • Directory …\xml\examples\0004 Movement
Use case, stock flow • Ending stock = starting stock + inflow – outflow • Starting context (instant at start date) • Flow/change context (duration from start to end) • Ending context (instant at end date) • Inputs have cross-context period matching • Starting stock’s instant date matches inflow & outflow duration starts • Both inflow & outflow need periodStart matching • Output result (ending stock) gets inflow/outflow duration ending date • Formula specifies period for ending stock
Use case, stock flow result’s period is duration end period start filtering
Stock Flow example • Try it, examine it, execute it online: • Directory …\xml\examples\0003 Stock Flow
Tuple filter • ParentTuple • Concept name of the fact’s tuple parent • AncestorTuple • Concept name of a fact’s ancestor • TupleSibling • Another variable’s fact is a sibling of this fact • TupleLocation • Another variable’s fact is a given relation to this fact • E.g., $a is “../eg:tupleB/*” related to this fact
GL-based tuple examples (tuples in, non-tuples out) • Trial balance in-balance checks • For each entry details section check if in-balance • Output string result item (for this example) • Trial balance ending balances report • For each account add changes to balance brought fwd • Aggregate account across entry detail sections • Output string result item (acct name & ending balance) • (Research into tuple generation is discussed later)
GL trial balance check <xbrli:xbrl> <gl-cor:accountingEntries> <gl-cor:entryHeader> <gl-cor:qualifierEntry …>balance-brought-forward</ …> <gl-cor:entryDetail> <gl-cor:amount …>242678.26</ …> <gl-cor:debitCreditCode …">D</ …> </gl-cor:entryDetail> … </ gl-cor:entryHeader> <gl-cor:entryHeader> <gl-cor:qualifierEntry …>standard</ …> <gl-cor:entryDetail> <gl-cor:amount …>242678.26</ …> <gl-cor:debitCreditCode …">D</ …> </gl-cor:entryDetail> … </ gl-cor:entryHeader> </ gl-cor:accountingEntries> </ xbrli:xbrl> accountbalances D – debit C - credit period’schanges Check if sections are in balance: sum(amts with ‘D’ siblings) = sum(amts with ‘C’ siblings)