# Calculate year-over-year growth from financial statements without fooling yourself

Compute YoY from annual and quarterly income statements: match the same period a year earlier, skip incomparable pairs, handle loss-making bases, and report margins in points.

Year-over-year (YoY) change is just a subtraction and a division. But if you don't first check whether the row a year back is actually comparable, you get numbers that look reasonable and mean nothing. This page turns the "when to compute YoY and when not to" rules into code, using the ZENITH Code [income statement endpoint](https://zenithcode.net/en/docs/income-statement).

- Find the prior period by "same fiscal month, one year earlier," not "the next row down."
- When accounting standard, consolidation scope, or period length differ, return a reason instead of a rate.
- Don't compute a growth rate when the prior value is zero or negative. Report margin changes in percentage points, not as a growth rate.

The examples use Toyota Motor (7203) annual figures, retrieved from the production API on October 27, 2026 at 16:50 JST.

We at [Crabgrass Inc.](https://crabgrass.co.jp/) build [ZENITH Code](https://zenithcode.net/en), an API for financial and disclosure data on Japanese companies. This article is an implementation guide for using our own data.

## Five checks before you compute YoY

YoY only means something when both periods were measured the same way. If any of these differ, part of the change has nothing to do with business performance.

| Check | What goes wrong if it fails |
|---|---|
| Exactly one year earlier | If a period is missing in between, you read two years of change as one |
| Same period type | Comparing a full year with a quarter, or Q1 with Q2, compares different lengths |
| Same period length | A 9- or 15-month transition period after a fiscal year-end change shows up as growth or decline |
| Same accounting standard | The year a company moves from Japanese GAAP to IFRS, revenue and operating income are defined differently |
| Same consolidation basis | Consolidated vs. standalone covers a different set of companies |

ZENITH Code returns the fields you need for each check:

| Field | Meaning |
|---|---|
| `fiscalPeriod` | Fiscal period end month (`YYYY-MM`). The fiscal year ended March 2025 is `2025-03` |
| `period` | `FY` (full year), `Q1`, `Q2`, `Q3`. Profit and loss for `Q2` and `Q3` is cumulative from the start of the fiscal year |
| `fiscalPeriodDays` | Length of the period in days. About 365 for a 12-month year, about 182 for a J-REIT's six-month period |
| `accountingStandard` | Accounting standard. Field names are the same regardless of standard |
| `consolidation` | `consolidated` or `nonconsolidated` (standalone). `null` when unknown |

## Find the same period a year earlier

A common mistake is to take "the next row" as the prior period. The API returns periods newest first, but the next row isn't always one year back.

- If a period is missing, the next row is two years back.
- J-REITs have two full-year (FY) rows per year, so the next row is six months back.
- After a fiscal year-end change, the next row isn't a 12-month period.

Instead, subtract one from the year in `fiscalPeriod` and look for a row with the same month and the same `period`.

```python
def same_period_last_year(rows, current):
    """Find the row of the same type (FY, Q1-Q3) with the same month one year earlier, or None."""
    year, month = current["fiscalPeriod"].split("-")
    target = f"{int(year) - 1}-{month}"
    for row in rows:
        if row["fiscalPeriod"] == target and row["period"] == current["period"]:
            return row
    return None
```

The same function works for quarters. Q2 of the fiscal year ending March 2026 (`2025-09`, `Q2`) is compared with Q2 of the prior year (`2024-09`, `Q2`). Both are year-to-date cumulative, so the result is a same-quarter-last-year comparison.

## Decide whether a pair is comparable

Next, decide whether the two periods can be compared. If not, return a reason code.

```python
def comparable(current, previous):
    """Return None if the pair is comparable, otherwise a reason code."""
    if previous is None:
        return "no_previous"
    std_now = (current.get("accountingStandard") or "").lower()
    std_prev = (previous.get("accountingStandard") or "").lower()
    if not std_now or std_now != std_prev:
        return "standard_changed"
    cons_now, cons_prev = current.get("consolidation"), previous.get("consolidation")
    if cons_now and cons_prev and cons_now != cons_prev:
        return "consolidation_changed"
    days_now, days_prev = current.get("fiscalPeriodDays"), previous.get("fiscalPeriodDays")
    if days_now is None or days_prev is None:
        return "length_unknown"
    if abs(days_now - days_prev) > 3:
        return "length_differs"
    return None
```

The reasoning behind each rule:

- **Compare accounting standards case-insensitively.** The sample responses in our docs return lowercase values such as `ifrs`. Don't flag a "change" because of letter case.
- **Compare consolidation only when both are known.** `null` means "unknown." If one side is `null`, this code still computes the change. Add `null` to the stop condition if you want to be strict.
- **Allow up to three days of difference in length.** A 12-month year can be 364 to 366 days depending on leap years and counting. In our docs' sample response (retrieved October 23, 2026), Toyota's fiscal year ended March 2025 is 364 days and the year ended March 2024 is 365. Requiring exactly 365 would throw out comparable years.
- **Stop when length is unknown.** If `fiscalPeriodDays` is `null`, you can't confirm the two periods are the same length.

The rule compares the two lengths with each other instead of requiring 12 months, so two J-REIT half-year periods (about 182 days each) still compare. If you only want annual comparisons, also require 360 to 367 days.

## Separate growth rates from point changes

For comparable pairs, compute the value: a growth rate for amounts, a point difference for margins.

```python
RATIO_FIELDS = {"grossMargin", "operatingMargin", "ordinaryMargin", "netMargin"}


def change(current, previous, field):
    """Return (value, reason). Ratios give a point difference; amounts give a growth rate."""
    reason = comparable(current, previous)
    if reason:
        return None, reason
    a, b = current.get(field), previous.get(field)
    if a is None or b is None:
        return None, current.get("nullReason") or previous.get("nullReason") or "missing_value"
    if field in RATIO_FIELDS:
        return a - b, None
    if b <= 0:
        return None, "previous_not_positive"
    return a / b - 1, None
```

### Skip growth rates on a zero or negative base

If the prior period had an operating loss, the growth rate flips sign. Going from −¥420 million to +¥610 million gives −245% by formula. Performance improved, but the number reads as a decline. A prior value of exactly zero can't be divided at all.

In these cases, return "prior period zero or negative" instead of a rate. Showing the two amounts side by side is clearer for the reader.

### Report margins in points

When operating margin goes from 11.87% to 9.98%, the change is −1.89 percentage points. Expressed as a growth rate it's −15.9%, a different number. To avoid mixing them, ratio fields use subtraction only.

API ratios are decimals between 0 and 1, so the difference is a decimal too. Multiply by 100 and add "pt" on screen: −0.0189 in the API, −1.89 pt on screen.

## Build a YoY table for every period

Combine the functions to get YoY for all periods.

```python
def yoy_table(rows, fields=("revenue", "operatingIncome", "operatingMargin")):
    """List YoY values and reasons for each field, newest period first."""
    table = []
    for current in sorted(rows, key=lambda r: r["fiscalPeriod"], reverse=True):
        previous = same_period_last_year(rows, current)
        entry = {"fiscalPeriod": current["fiscalPeriod"], "period": current["period"]}
        for field in fields:
            entry[field] = change(current, previous, field)
        table.append(entry)
    return table
```

With `limit=5` you get five years, but the oldest has nothing to compare with, so you get four YoY values. For N years of YoY, request `limit` = N+1. The default `limit` is 10 and the maximum is 40.

For Toyota's fiscal year ended March 2025, the output is:

```text
2025-03 FY revenue          (0.06522580777497455, None)
2025-03 FY operatingIncome  (-0.10412009563353486, None)
2025-03 FY operatingMargin  (-0.018870933445311433, None)
```

| Item | FY ended March 2024 | FY ended March 2025 | YoY |
|---|---:|---:|---:|
| Revenue | ¥45.10 trillion | ¥48.04 trillion | +6.52% |
| Operating income | ¥5.35 trillion | ¥4.80 trillion | −10.41% |
| Operating margin | 11.87% | 9.98% | −1.89 pt |

YoY is computed from the raw yen values. Recomputing from the rounded ¥5.35 trillion and ¥4.80 trillion gives −10.28%, off by 0.13 points. Calculate with raw values and round only for display.

## Format it for the screen

Turn the value and reason into text in one function. `Intl.NumberFormat` with `signDisplay: "exceptZero"` adds a `+` to positive numbers.

```javascript
const REASON_TEXT = {
  no_previous: "no data for the same period last year",
  standard_changed: "different accounting standard",
  consolidation_changed: "consolidated vs. standalone",
  length_differs: "different period length",
  length_unknown: "period length unknown",
  missing_value: "value not available",
  previous_not_positive: "prior period zero or negative",
  non_jpy_material: "reported in a currency other than yen",
};

const pct = new Intl.NumberFormat("en-US", { style: "percent", minimumFractionDigits: 1, maximumFractionDigits: 1, signDisplay: "exceptZero" });
const pt = new Intl.NumberFormat("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 2, signDisplay: "exceptZero" });

function formatChange([value, reason], isRatio) {
  if (value === null) return `n/a (${REASON_TEXT[reason] ?? reason})`;
  return isRatio ? `${pt.format(value * 100)} pt` : pct.format(value);
}
```

Don't stop at "n/a"; show the reason. Readers can tell missing data from a fiscal year-end change, and the reason tells them what to look up in the earnings summary or securities report.

## Comparing two companies on the same period

The same logic applies across companies:

- Line up only periods with the same `fiscalPeriod` and `period`. A March year-end company and a December year-end company cover different months even when both say "fiscal 2026."
- Show the accounting standard and period length on screen, and mark any difference.
- Matching fields and conditions are only the minimum. Different industries or business mixes give the same operating margin a different meaning.

See [Compare revenue and operating margin of two companies](https://zenithcode.net/en/docs/cookbook/applied/practice-compare-two-companies) for more.

## Read the numbers carefully

- **J-REITs have two full-year rows per year.** `fiscalPeriodDays` is about 182. Comparing with the next row compares with six months earlier.
- **`Q2` and `Q3` are cumulative.** Compare like with like (`Q2` with `Q2`). For a single three-month quarter, take the difference between cumulative figures. See [Cumulative quarters and TTM](https://zenithcode.net/en/learn/ttm-and-cumulative-quarters).
- **Changes in consolidation scope don't show in the flag.** A share exchange or a change in the scope of consolidation can break continuity without changing `consolidation`. Check disclosures for years with large acquisitions.
- **The year a company first acquires a subsidiary at year-end, profit and loss is standalone.** The income statement row is `nonconsolidated` while the balance sheet row for the same period is `consolidated`. If the flag differs from the prior year, the code above stops.
- **Newly listed companies may lack pre-listing income statements.** The first earnings summary after listing often doesn't include the prior full-year P&L. You'll get "no data for the same period last year."
- **Non-yen periods have `null` amounts.** Companies that report in US dollars (6269 and 9399) return `nullReason` of `non_jpy_material`. The code above passes that reason through.
- **Prior-period values can change later.** Corrections, or replacing earnings-summary figures with securities-report figures, can update the prior year. If a stored YoY no longer matches, check the filing IDs of both periods. See [Track the source of every financial figure](https://zenithcode.net/en/docs/cookbook/applied/practice-statements-and-sources).

## Summary

- Find the prior period by subtracting one year from `fiscalPeriod`, matching the month and `period`.
- Return a reason instead of a rate when accounting standard, consolidation, or period length differ.
- Skip growth rates on a zero or negative base, and report margins in points.
- Compute from raw yen values and round only for display.

## Related

- [Income statement API docs](https://zenithcode.net/en/docs/income-statement)
- [Accounting standards in Japan (JGAAP, IFRS, US GAAP)](https://zenithcode.net/en/learn/accounting-standards)
- [Cumulative quarters and TTM](https://zenithcode.net/en/learn/ttm-and-cumulative-quarters)
- [Compare revenue and operating margin of two companies](https://zenithcode.net/en/docs/cookbook/applied/practice-compare-two-companies)
- [Track the source of every financial figure](https://zenithcode.net/en/docs/cookbook/applied/practice-statements-and-sources)
- [Sample code repository (company-analysis template)](https://github.com/Crab-grass/zenith-code-examples/tree/main/templates/company-analysis)

A Japanese-language walkthrough with screenshots is on [Qiita](https://qiita.com/Sohei-Taniguchi-CG/items/e3942e2e1d71ef30054a).

---
Page: https://zenithcode.net/en/docs/cookbook/applied/practice-periods-and-yoy
日本語: https://zenithcode.net/docs/cookbook/applied/practice-periods-and-yoy.md
Site guide for AI tools: https://zenithcode.net/llms.txt
