Can I calculate gross margin from SEC XBRL data?
The evidence
Gross profit is not reliably an annual tag.
General Mills has 128 gross-profit facts and every one of them is a quarter, not a year. A pull keyed to that tag records “no gross profit series” for a filer that plainly has one. Compute gross margin from revenue and cost of goods, and label it calculated rather than measured.
The per-concept endpoint cannot prove a tag is absent.
It returned 404 for Coca-Cola on tags that the full company-facts endpoint shows the filer plainly uses. Treating that 404 as “the filer does not tag this” silently dropped Coca-Cola and Mondelez out of a CPG study. Use the company-facts endpoint: one request per filer, and absence in it is real absence.
Taking the first matching tag variant loses filers who switched mid-window.
Coca-Cola tags revenue under an older variant in the early years and a newer one later, while cost of goods moved the other way, so the two never intersected in a recent year. Union every variant and resolve per fiscal year. That alone took usable filers from 34 to 48 of 59.
A plausibility band catches the rest.
A computed gross margin far outside a stated band is a measurement failure, not a business fact. ADM read 5.5% to 7.0% for thirteen years and then −240% from FY2022 — a level break with no business event behind it. Reject or re-resolve those years and publish which ones they were.
What would have to be true for this to be wrong
Measured October 25, 2026 against 59 filers pulled from data.sec.gov company facts. The 196-of-264 figure counts filer-years where more than one allowlisted revenue tag carried a value and the cost-tested choice differed from the precedence choice. Every filer and every exclusion is published on the study page.
Every row behind this answer is published in the standing study at cultmath.com/research/cpg/margin-recovery, which is re-run on a schedule and corrected in place, dated.
Published 2026-10-25 by Ipalibo Da-Wariboko, CULT+MATH LLC. Where a number could not be sourced, this page says so and gives none.
This is one of six decisions covered in the cpg decision brief — each with the evidence behind it, who owns it, who it is contested with, and what would have to be true for the answer to flip.
See the brief →