## Formulas

A formula expresses a set of rules for constructing an output XBRL fact by transforming the values to which the variables in the formula's variable set have evaluated. The values of the variables are obtained from an input XBRL instance and its supporting DTS or from the application processing the formula.

The value rule is an XPath expression that yields the value to be assigned to the fact. It can be a simple expression, such as a constant, or it can contain terms which refer to variables and parameters of the variable set, chained values from other variable sets, and/or computed values from custom and built-in functions.

In XBRL, non-fraction numeric facts are reported with information about their accuracy in the form of a precision/decimals attribute. Therefore formulae may contain accuracy rules governing the determination of the accuracy to be asserted for an output fact.

Along with rules for determining output fact values and their precision, formulae specify or imply aspect rules that determine values for all of the output aspects required to interpret output values. Rules for determining the output concept, the output context, and the output units of measurement (for numeric facts) are all different types of aspect rules.

An aspect may be obtained (in part or full) from a bound variable of the evaluation by specifying a source. The source may be specified on a rule or may be inherited from a source on the formula (or tuple) element. When there are multiple sources, the nearest one to an aspect rule prevails.

When a formula is inserted, it has no accuracy or aspect rule (screenshot below).

Accuracy and aspect rules are defined within the formula’s content and are added (or removed) via the context menu. The screenshot below shows a formula with all possible accuracy and aspect rules.

In the Details entry helper, accuracy and aspect rules are displayed in additional sections.

## Accuracy rule

Kind: precision or decimals

Value: XPath expression

## Aspect rules

Aspect rules are grouped by kind.

### Concept rules

Kind: qname, expr, or source

Value: Concept’s QName, XPath expression, or source variable (or the uncovered QName)

### Entity identifier rules

Source: source variable (or the uncovered QName)

Scheme/value: XPath expressions

### Period rules

Kind: instant, duration, forever or source

Value: Value’s XPath expression, start/end/source, no value or source variable (or the uncovered QName)

### Explicit dimension rules

Dimension: QName of the dimension, affected by the explicit dimension rule.

Kind: qname, exp, omit or source

Value: Member’s QName, Member’s XPath expression, no value or source variable (or the uncovered QName)

### Typed dimension rules

Dimension: QName of the dimension, affected by the typed dimension rule.

Kind: xpath, value, omit or source

Value: XPath expression, XML element, no value or source variable (or the uncovered QName)

### Open context component rules

OCC rules are grouped by kind, that is, by segment OCC rules and scenario OCC rules.

Source: Source variable defined in the first OCC rule.

For each OCC rule:

Kind: empty, fragments, or xpath

Value: No value, XML elements, or XPath expression

### Unit rules

The Boolean flag Augment specifies whether the source aspect value has to be used or not.

For each unit multiplication/division rule:

Kind: *measure, /measure or *source, /source

Value: Measure’s XPath expression or source variable (or the uncovered QName)