1 16 th XBRL International Conference Demystifying XBRL Formulas December 5, 2007 Herm Fischer
2 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
3 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
4 FDIC contract motivates solutions oConceptual prototype based on XSL oExcel-like, implicit matching (now in use) “ - Rule base Requirements IWD XPath syntax chosen “ - Functions spec drafted. Formula drafts, some implementations 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
5 Information producer oValidate data types and values oConsistency and quality checks Information consumer o (ditto) oCompleteness checks oAugment received data with calculated values oAugment received data with annotations
6 Calculation linkbase oWell behaved roll-ups of compatible numerical values o(Proposed) Aggregation of dimensional values Calculation linkbase can’t do oCross-context (ending bal = starting bal + changes) oCross-unit (dollars = price per share X nbr shares) oDimensional aggregation (all = red wine + white wine) oMissing items checks oThreshold and limits (sum amounts ± € 5)
7 Input inst. DTS contexts units fact items Formula LB* Formula Processor Output inst. computed fact items *Formula LB is part of DTS
8 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
9 Input inst. DTS contexts units fact items Formula Processor Output inst. computed fact items Formula LB* Parameter ( select expr.) custom function variable filter loclabelref. formula arc precondition *Formula LB is part of DTS
10 Input inst. DTS contexts units fact items 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 Output inst. computed fact items Formula Processor *Formula LB is part of DTS
11 Test that “assets = liabilities + equity” oInput instance has assets, liabilities, and equity oOutput boolean test result, true or false
12 Processing flow Input inst. DTS assets, liab, equity Formula LB* Formula Processor Output inst. Test result boolean *Formula LB is part of DTS
13 Instance document input has values to test Output is the boolean result of testing the sum same context units match
14
15
16
17
18
19 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)
20 Taxonomy has monetary concepts for assets, liabilities, equity Here output is the assets concept (vs. boolean) Last example:
21 Instance document input has values to add Output is the monetary result of adding the sum same context units match
22
23 Parameter Function declaration Formula Variables Filters Precondition Generic label Generic reference
24 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)
25 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)
26 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)
27 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)
28 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)
29 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)
30 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
31 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)
32 Concept filter Dimension filter Entity filter General filter Period filter Tuple filter Unit filter Value filter PWD-2 additions: Boolean, Match, Relative
33 Filter by name of concept Filter by facet of concept ◦ Balance ◦ Data type ◦ Substitution group ◦ Period type ◦ Custom attribute
34 Sum test uses a concept filter on each variable eg:assets
35 Match completely another variable’s period Match date date/time of: ◦ periodStart ◦ periodEnd ◦ periodInstant ◦ periodInstantDuration Matching by an XPath 2 expression
36 Ending balance = beginning balance + changes Inputs have cross-context matching oStarting balance’s date matches duration’s start oEnding balance’s date comes from duration’s end
37
38 PeriodStart filter matches change’s duration start date to beginningBalance’s instant date <pf:periodStart date=“xfi:period-instant( xfi:period($beginningBalance))” />
39 Location (tuple nesting) (both tuple & item) Concept (namespace & name) ( “ ) Entity identifier (item only) Period ( “ ) Segment (complete, nonXDT, or dimension) ( “ ) Scenario ( “ ) ( “ ) Unit (numeric items only)
40 Context Entity - IdentifierAll - SegmentAll PeriodAll ScenarioAll Unit Name MeasureAll ConceptAll Default Implicit Search Criteria + Explicit Criteria from Variable Definition Context Entity - Identifier - Segment Period Scenario Unit Name Measure Concept‘Balance’ = Search Criteria for Variable Context Entity - IdentifierAll - SegmentAll PeriodAll ScenarioAll Unit Name MeasureAll Concept‘Balance’ Carried forward Implicit Search Criteria Context Entity - Identifier01 - SegmentNone PeriodI-2007 ScenarioNone Unit Name MeasureUSD ConceptAll LocationAll Location All LocationNot tuple
41 Context Entity - Identifier01 - SegmentNone PeriodI-2007 ScenarioNone Unit Name MeasureUSD ConceptAll Beginning Balance Implicit Search Criteria + Explicit Criteria from Variable Definition Context Entity - Identifier - Segment PeriodInst match duration start Scenario Unit Name Measure Concept‘Changes’ = Search Criteria for Variable Context Entity - Identifier01 - SegmentNone PeriodD-2008 ScenarioNone Unit Name MeasureUSD Concept‘Changes’ Carried forward Implicit Search Criteria Context Entity - Identifier01 - SegmentNone PeriodD-2008 ScenarioNone Unit Name MeasureUSD ConceptAll LocationNot tupleLocation not tuple LocationNot tuple
42 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
43 Result concept takes concept of a bound variable instead of loc & arc
44 Try it, examine it, execute it online: ◦ Directory …\xml\examples\0004 Movement
45 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
46 result’s period is duration end period start filtering
47 Try it, examine it, execute it online: ◦ Directory …\xml\examples\0003 Stock Flow
48 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
49 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)
50 balance-brought-forward D … standard D … account balances period’s changes D – debit C - credit Check if sections are in balance: sum(amts with ‘D’ siblings) = sum(amts with ‘C’ siblings)
51 Just an XPath 2 expression ◦ Need to test if sibling of amount is credit code D ◦ test=“../gl-cor:debitCreditCode eq ‘D’”
52
53 Value matches an XPath 2 expression Not Nil test Nil test Precision expression
54 balance-brought-forward 5100 Supplies account D beginning_balance … standard … … aggregate by account skip ending_balances
55
56 Added 2 more variables ◦ For each account Get amount for ending-balance entry with ‘C’ (credit) code Get amount for ending-balance entry with ‘D’ (debit) code ◦ Change equation to test Sum (credits which are not ending-balance - debits which are not ending-balance + credit which is ending-balance – debit which is not ending-balance) < 1.00
57 Try it, examine it, execute it online: ◦ Directory …examples\0007 GL Examples Instance-trial-balance-check.xml Instance-test-ending-balance.xml Instance-compute-ending-balance.xml
58 Explicit Dimension filter ◦ Fact has QNamed dimension (in context or default) ◦ Constrained if arcs to allowed member concepts Dimension Member filter ◦ Constrains to member’s children or its descendants Typed Dimension filter ◦ Typed dimension is specified by QName ◦ XPath 2 expression tests dimension value
59 Primary items with multiple dimensions ◦ Dimensions explicity filtered ◦ Remaining dimensions implict matched ◦ Remainder of segment/scenario implicit matched Example has 2 dimensions (product, region) ◦ Aggregation check by product or region requires implicit matching of other dimension
60 Test aggregation of each member Products & region dimensions have member hierarchy
61 Multiple periods for used dimensions Multiple dimensions per contexts (Charlie’s aggregation example)
62 Will require checking of aggregation for ◦ Product dimension ◦ Region dimension Formula shown for product dimension (region is same except for dimension name) Demonstrates mixed explicit/implicit dimension filtering
63
64 Try it, examine it, execute it online: ◦ Directory …examples\0005 Pharmaceutical
65 Weighted average of its dimensional children by another primary item
66 Excel formulas: Make PD controlling fact, get PD and EV of dimensional children General variable for PDxEV member matching
67
68 Try it, examine it, execute it online: ◦ Directory …\xml\examples\0006 Weighted Avg
69 Boolean filter ◦ Allows grouping and/or filter expressions Match filter ◦ Specifies specific aspects to match Relative filter ◦ Specify matching all non-covered aspects
70 Assertions are alternate to formula item production Fact Consistency assertion ◦ Produced fact matches corresponding fact(s), in value Existence assertion ◦ Filtering constructs find existing fact item Value assertion ◦ Value-assertion expression is true
71 Built-in functions ◦ Functions 1.0 December 7, htm User-defined functions ◦ Signatures provided in linkbase resources ◦ Code provided to formula processor somehow Maybe XQuery Maybe Java or other coding language
72 Precision ◦ xfi:precision( item ) ◦ xfi:decimals( item ) Accessors ◦ xfi:context( item ) ◦ xfi:unit( item ) ◦ xfi:period( context ) ◦ xfi:period-start, :period-end, :period-instant( period )
73 Comments to re-issued PWD Implement formula processors Implement formula editors Discuss additional desired features ◦ Formula chaining ◦ Tuple output production ◦ Multiple-input instances, DTSes ◦ other
74 Herm Fischer THANK YOU! Let us help you get your first formulas easily!