DEV Community

Eqvero
Eqvero

Posted on

When Duplicate XBRL Facts Disagree: Check Precision Before Picking a Value

A filing can contain the same revenue fact in a financial statement and again in a note. If your parser keeps only the last occurrence, a rounded value can replace a more precise one. If it sums both, revenue doubles. Neither error requires a malformed filing.

Consider two fictional values for the same company, concept, duration, unit and dimensions:

1200, decimals=-2    # rounded to the nearest hundred
1234, decimals=0     # rounded to the nearest unit
Enter fullscreen mode Exit fullscreen mode

These values differ, yet their rounding ranges overlap. Treating every unequal pair as a conflict creates noise; taking the first value hides which occurrence had greater precision. The problem gets harder when two values have the same reported precision but disagree.

Group before comparing

Start with a semantic identity that includes the entity, expanded concept name, period, unit and complete dimensional context. Preserve the filing accession and source location for every occurrence. A context ID is useful provenance, but two different IDs can describe equivalent contexts, so it is not a sufficient semantic key by itself.

Compare occurrences within one filing before choosing an observation across filings. A later filing can report a revised comparative value; that is a separate versioning decision, not a duplicate to erase. The XBRL guidance on duplicate facts describes duplicate facts and consistency in more detail.

Compare rounding ranges

For a finite decimals value d, this example uses a half-unit rounding interval of 0.5 * 10**(-d). It uses closed endpoints as a practical screen: touching intervals are sent for review because boundary and rounding rules require extra care. These are screening intervals, not a substitute for a full XBRL conformance implementation.

from decimal import Decimal


def interval(value, decimals):
    value = Decimal(str(value))
    half = Decimal("0.5") * (Decimal(10) ** -decimals)
    return value - half, value + half


def classify(rows):
    ranges = [interval(value, decimals) for value, decimals in rows]
    left = max(low for low, high in ranges)
    right = min(high for low, high in ranges)
    if left > right:
        return "conflict"
    if left == right:
        return "boundary_review"
    return "overlap"


assert classify([(1200, -2), (1234, 0)]) == "overlap"
assert classify([(1200, -2), (1300, -2)]) == "boundary_review"
assert classify([(1200, -2), (1400, -2)]) == "conflict"
assert classify([(100, 0), (101, 0), (102, 0)]) == "conflict"
Enter fullscreen mode Exit fullscreen mode

The last case matters when there are more than two occurrences. Checking only neighboring pairs can suggest consistency even though the whole group has no common intersection. Compute the intersection across the entire group.

The code accepts numeric facts with finite integer decimals. XBRL also permits INF for exact values, and real inputs may have nil facts, malformed attributes or other data types. Handle those explicitly in a production parser. Do not treat a missing precision attribute as zero. For inline XBRL, apply the format, sign and scale transformations first; the decimals attribute describes precision of the transformed value. The Inline XBRL specification describes those attributes.

Keep both the choice and the evidence

When ranges overlap, an application can choose the occurrence with the highest decimals as its display value, while keeping all occurrences available. That is a selection policy, not proof that the chosen number is exact. Store the selected value, precision, accession and source location alongside the full set of inputs and the comparison result.

For a conflict or a boundary case, avoid silently choosing a value for an automated ratio. Surface the occurrences to a reviewer and link to the statement or note. The right response might be a filing correction, a context-matching bug in the parser, or a disclosure that requires interpretation.

Do not merge facts merely because their labels look alike. Different taxonomy namespaces, units, periods or dimensional members can describe different economic quantities. Conversely, equivalent contexts may use different local identifiers. Normalize the context first, then compare values, and retain the raw IDs for audit.

Keep revisions separate

Suppose a later annual report repeats the previous year's revenue with a revised figure. Preserve each filing's observation and its acceptance time. A current research view can select a later comparative under a documented policy; a historical backtest must restrict itself to information available at its decision time. The duplicate check above runs inside each filing and does not decide which filing is authoritative.

For an overview of SEC data access and the scope of aggregated company facts, see the SEC EDGAR API documentation. Filing-level inline XBRL is the place to inspect individual occurrences and their source contexts.

Top comments (0)