Data Modeling

An inventory stockout coverage model should start with expected availability, not sales. The core idea is simple: create a fact table at a declared product-location-time grain, mark whether the item was expected to be available, observe whether stock was actually available, and calculate stockout exposure from the gap between those two facts.

What the model must answer

Inventory stockout coverage models are useful when the business needs to know more than current inventory balance. A balance can tell you how many units were on hand at a cutoff. It does not, by itself, tell you whether the product was supposed to be available, whether the location was open, whether the SKU was ranged, or how long the item was unavailable during expected selling time.

The modeling question is: for each product, location, and period, was stock expected to be available, and was it actually available?

This separates three ideas that are often blended together:

  • Eligibility: the product-location was in scope for availability measurement.
  • Expectation: the business expected the item to be sellable, pickable, or usable during that period.
  • Observation: the available stock signal showed the item was or was not available.

That separation matters because a product that is not ranged at a store is not a stockout. A closed location is not a stockout. A discontinued SKU may not be a stockout. A product with expected demand but no available units usually is.

Declare the grain before choosing measures

The most important design decision is the grain of the stockout coverage fact table. A common starting point is one row per SKU, per location, per calendar date. That grain is easy to explain and works for daily reporting.

Daily grain is not always enough. If the business cares about partial-day outages, same-day replenishment, store opening hours, or ecommerce availability during the day, use a smaller period such as SKU-location-hour or SKU-location-availability-window.

A good grain statement looks like this:

One row represents one SKU at one location during one measurement period, whether or not stock was available, if the SKU-location-period is in the availability measurement scope.

That last phrase is important. If you only load rows when inventory exists, stockouts disappear from the model. The fact table must include expected rows with zero availability, otherwise missing stock becomes missing data.

Modeling rule

If the row disappears when stock disappears, the model cannot measure stockouts. Build the expected availability scaffold first.

Build the stockout coverage star schema

A practical design uses a periodic coverage fact table surrounded by product, location, date, and policy dimensions. The fact table should carry numeric exposure and outcome measures. Dimensions should describe the product, location, calendar, and business rules used to decide whether the item was expected to be available.

The fact table should not try to encode every explanation as a column. Use dimensions for stable descriptive context, and use measures for additive or semi-additive quantities such as expected minutes, available minutes, stockout minutes, expected day count, and stockout day count.

A useful model usually includes these concepts:

  • Expected availability flag: whether this SKU-location-period belongs in the denominator.
  • Observed availability flag: whether stock was available according to the chosen observation rule.
  • Expected exposure: the amount of time or countable opportunity where availability was expected.
  • Available exposure: the portion of expected exposure where stock was available.
  • Stockout exposure: expected exposure minus available exposure.
  • Reason classification: a controlled explanation when a period is excluded or unavailable.
Table Recommended grain Purpose
fact_inventory_availability_coverage One row per SKU, location, and measurement period Stores expected exposure, available exposure, stockout exposure, and availability flags.
dim_product One row per product version or product key Describes SKU, category, brand, pack, lifecycle attributes, and other product context.
dim_location One row per location version or location key Describes store, warehouse, region, channel, and operating context.
dim_date One row per calendar date Supports calendar reporting such as day, week, month, fiscal period, and holiday flags.
dim_availability_policy One row per expectation rule or policy version Explains why the product-location-period was expected, excluded, or governed by a specific measurement rule.
dim_stockout_reason One row per controlled reason Classifies true stockouts separately from closures, not-ranged periods, planned outages, and unknown source gaps.

Separate expectation rules from stock observations

Stockout analytics become unreliable when the model treats every zero balance as a stockout. Zero stock is only a stockout when the item was expected to be available.

Expectation is usually derived from business rules such as assortment status, store operating calendar, launch date, discontinuation date, channel eligibility, replenishment policy, and planned closures. Observation is derived from inventory availability signals such as available-to-sell quantity, on-hand quantity adjusted for reservations, pickable quantity, or a system-specific availability indicator.

Keep these rules separate in the model. If the expected availability rule changes, you should be able to explain whether the denominator changed. If the observed availability rule changes, you should be able to explain whether the numerator changed.

For example, a store may carry a SKU only after its assortment start date. Before that date, the expected availability flag should be false. After that date, a zero available-to-sell quantity during open hours can contribute to stockout exposure.

Operator checkpoint

A zero quantity is not automatically a stockout. Ask whether the SKU-location-period was expected to be available before counting it in the denominator.

Hypothetical example with reconciled measures

Consider one SKU at one store for one week. The store is open 720 minutes per day for the first six days. On the seventh day, the location is closed, so the product is not expected to be available for customer purchase.

In this hypothetical example, the item is partially unavailable on the second day, fully unavailable on the third and fourth days, and replenished before opening on the fifth day.

The reconciled measures are:

  • Expected minutes: 4,320, calculated as 6 open days multiplied by 720 expected minutes.
  • Available minutes: 2,640, calculated as the sum of available minutes during expected periods.
  • Stockout minutes: 1,680, calculated as expected minutes minus available minutes.
  • Coverage rate: 61.1 percent, calculated as 2,640 divided by 4,320.
  • Stockout exposure rate: 38.9 percent, calculated as 1,680 divided by 4,320.
  • Days with any stockout: 3, covering the second, third, and fourth days.
  • Full stockout days: 2, covering the third and fourth days.

The closed day does not reduce the coverage rate because it is not part of expected availability. This is the main reason to model expectation explicitly.

Day Expected minutes Available minutes Stockout minutes Interpretation
Day 1 720 720 0 Expected and fully available.
Day 2 720 480 240 Expected and partially stocked out.
Day 3 720 0 720 Expected and fully stocked out.
Day 4 720 0 720 Expected and fully stocked out.
Day 5 720 720 0 Expected and replenished before opening.
Day 6 720 720 0 Expected and fully available.
Day 7 0 0 0 Closed or otherwise not expected, so excluded from the denominator.
Total 4,320 2,640 1,680 Coverage rate is 2,640 divided by 4,320, or 61.1 percent.

Derive stockout periods from contiguous expected gaps

A daily or hourly coverage fact table is the best base for reporting, but operators often also need stockout periods. A stockout period is a contiguous run where the item was expected to be available and stock was missing.

You can derive a stockout period table from the coverage fact by grouping adjacent periods where expected availability is true and stockout exposure is greater than zero. The derived table can have one row per SKU-location-stockout episode.

A stockout period table usually includes:

  • Product key and location key: the affected item and place.
  • Stockout start timestamp: the first expected period with missing stock.
  • Stockout end timestamp: the point when availability returned or expectation ended.
  • Expected exposure during episode: the denominator within the episode.
  • Stockout exposure during episode: the missing-stock exposure within the episode.
  • Recovery reason: replenishment, correction, assortment change, closure, or unknown.

Do not replace the base coverage fact with only an episode table. Episode tables are useful for duration and incident reporting, but the periodic fact remains the safer denominator for coverage rates, trends, and reconciliation.

Derived episode field Example value Why it matters
Product-location SKU A at Store 10 Identifies the affected availability promise.
Episode start Day 2, first unavailable period Shows when missing stock began.
Episode end Day 5, availability restored before opening Shows when the stockout ended.
Calendar span 3 days Useful for incident-style reporting.
Stockout exposure 1,680 expected minutes Reconciles to the periodic coverage fact.
Episode type Partial start, full middle days Prevents a partial outage from being reported as three full days if that is not the intended metric.

Rules for measures that reconcile

The model should make common inventory availability measures reconcile from the same base rows. If two dashboards calculate coverage from different denominators, trust will erode quickly.

Use these measure rules as a starting point:

  • Expected SKU-location-periods: count rows where expected availability is true.
  • Available SKU-location-periods: count expected rows where the observed availability rule says stock was available.
  • Stockout SKU-location-periods: count expected rows where stock was not available.
  • Expected exposure: sum expected minutes, hours, or weighted opportunity.
  • Available exposure: sum the portion of expected exposure with available stock.
  • Stockout exposure: expected exposure minus available exposure.
  • Coverage rate: available exposure divided by expected exposure.
  • Stockout exposure rate: stockout exposure divided by expected exposure.

For daily reporting, decide whether a partially unavailable day counts as available, unavailable, or partial. The most transparent design stores both point-in-time flags and exposure measures when the source data supports them.

Metric guardrail

Coverage rates should reconcile from additive exposure measures. Avoid dashboard-only formulas that cannot be traced back to fact rows.

Common stockout modeling failure modes

The most common failure is using sales as the only availability signal. Sales prove that stock was available at some point, but no sales do not prove a stockout. Demand may have been low, the store may have been closed, or the item may not have been expected to sell.

Another failure is treating missing source rows as zero stock. Missing rows can mean the upstream system did not send a snapshot. If missing data becomes a stockout, operational data quality issues will be reported as inventory failures.

Watch for these specific problems:

  • No expectation scaffold: stockout rows never appear because only positive inventory rows are loaded.
  • Changing assortment rules: historical denominators shift without explanation.
  • Mixed grains: daily availability is joined to hourly operating windows without a clear allocation rule.
  • Unclear zero semantics: zero on hand, zero available-to-sell, and zero pickable quantity are treated as identical.
  • Late-arriving product or location attributes: old rows are restated without preserving the rule context used at measurement time.
  • Closed periods counted as stockouts: unavailable time is inflated because operating calendars are not modeled.

Implementation checklist

Build the model in layers. Start with the denominator, then add observations, then derive episodes. This order prevents the common mistake of letting source availability rows define the measurement universe.

  1. Declare the measurement grain. Choose SKU-location-date, SKU-location-hour, or another period based on the decisions the model must support.
  2. Create the expectation scaffold. Generate rows for every product-location-period that could be measured.
  3. Apply expectation rules. Mark whether the item was expected to be available using assortment, operating calendar, launch, discontinuation, and policy rules.
  4. Attach stock observations. Join inventory availability signals to the scaffold without dropping expected zero-stock rows.
  5. Classify exclusions and gaps. Separate not ranged, closed, planned outage, missing source data, and true stockout.
  6. Calculate additive exposure measures. Store expected exposure, available exposure, and stockout exposure at the fact grain.
  7. Derive contiguous stockout episodes. Build period-level reporting from the base fact rather than replacing it.
  8. Reconcile published metrics. Confirm coverage rate, stockout rate, and episode counts all tie back to the same expected exposure denominator.

Key takeaways

  • Model stockout coverage from expected availability, not from sales alone.
  • Use a declared product-location-time grain so the denominator is explicit and repeatable.
  • Keep expectation rules separate from observed stock availability signals.
  • Store additive exposure measures so coverage rates, stockout rates, and episode counts reconcile.
  • Derive stockout periods from the periodic coverage fact instead of making episodes the only source of truth.

Next step

Pick one important SKU family and one location group. Draft the grain statement, list the expectation rules, and build a small seven-day coverage table by hand. If the expected exposure, available exposure, and stockout exposure do not reconcile on paper, fix the model before implementing it in the warehouse.

Recommended next reads