eCommerce demand forecasting is the estimate of how many units of each product customers will want to buy over a set period. Every purchase order you send already has one inside it, written down or not.
Plenty has been written about forecasting methods, and far less about getting a clean number out of a real store, where the sales history has stockouts, promotions and a season in it.
This article takes one product from raw Shopify data to a purchase order quantity, checks whether the forecast was any good, and then covers the products that need a different method and the point where a spreadsheet stops being enough.
What a demand forecast has to cover
A forecast for "next month" answers the wrong question. The order you place today doesn't arrive today, and it has to last until the order after it arrives.
forecast window = supplier lead time + days between order

The window one purchase order has to cover, with the example product's dates.
The example runs on one product, a 24 oz insulated bottle in black, with the purchase order going out on September 28.
|
Input |
Value |
|
Supplier lead time |
56 days |
|
Days between orders |
28 days |
|
Forecast window |
84 days, September 28 to December 20 |
|
On hand today |
640 units |
|
On order, arriving October 12 |
600 units |
|
Case pack |
24 units |
|
Selling price |
$32 |
The finished forecast comes first. Each section below explains one line of it.
|
Line |
Units |
|
Trailing average carried forward for 84 days |
1,462 |
|
Corrected baseline with the season applied |
1,960 |
|
Planned promotion that last year didn't have |
+ 60 |
|
Demand forecast for the window |
2,020 |
|
Resellable returns, 5% |
− 101 |
|
Safety stock |
+ 461 |
|
On hand and on order |
− 1,240 |
|
Purchase order, rounded up to cases of 24 |
1,152 |
Put the trailing average through the same returns, safety stock and case-pack steps and it orders 504 units, less than half as many, for a window that includes Black Friday.
Why Shopify sales history is not demand
Sales are demand that happened to meet stock at a normal price. Several things in a store's history break that link, and each one pushes the forecast in a known direction.
|
What's in the history |
What it does to the forecast |
Where it gets fixed |
|
Days out of stock |
Zero sales read as zero demand, so you order less of what just sold out |
How to correct sales history for stockouts |
|
Promotion weeks |
A discount week reads as a normal week, so the baseline runs high |
How to separate promotions from baseline demand |
|
Returned units |
Units that came back still count as sold |
How to account for returns in a demand forecast |
|
A season |
An average taken in slow months gets applied to busy ones |
How to add seasonality to a demand forecast |
|
Plans that haven't happened yet |
Last year's calendar gets repeated whether or not this year matches it |
How to add your marketing calendar to the forecast |
How to pull demand history from Shopify
Shopify's default inventory reports are built for a quick read, and two of them matter here. According to Shopify's inventory report definitions, Inventory sold daily by product divides quantity sold by every day in the period, in stock or not. Products by days of inventory remaining, which the Help Center calls Inventory remaining per product, works out its daily rate from sales over the last 28 days.
So a variant that sat at zero for a week shows a lower daily rate, and a longer runway, than it really has.

Analytics > Reports filtered to the Inventory category, with the three reports this article uses marked.
The fix is to ask for in-stock days alongside units. The ShopifyQL inventory dataset carries both days_in_stock and days_out_of_stock as metrics, defined per variant for whatever period you select.
-
Go to Analytics > Reports and open any inventory report.
-
Open the query editor and replace the query with the one below.
-
Export the result as a CSV.
FROM inventory
SHOW inventory_units_sold, days_in_stock, days_out_of_stock
WHERE inventory_is_tracked = true
GROUP BY product_variant_id, product_title, product_variant_title, product_variant_sku
TIMESERIES week
SINCE -8w UNTIL -1d
ORDER BY week ASC
The query asks for the last eight weeks. Change SINCE and UNTIL for a different period.
Units sold with days in stock and days out of stock, by variant and week
Limits to know before you trust the output:
-
Inventory metrics go back to October 1, 2023 and no further.
-
Since October 1, 2026 inventory reports count On hand quantity, which includes committed and unavailable units. A variant with nothing left to sell but ten damaged units on the shelf may not register as out of stock. Data from before that date still uses Available, so a query that spans October 1, 2026 mixes the two.
-
A day counts as out of stock when it ended at zero or below. A variant that sold out at noon still shows as in stock that day, with its morning sales counted.
-
Stores that sync stock from an ERP should check a few dates by hand, because integration faults that zero out inventory show up as stockout days that never happened.

The Inventory page, where Available and On hand sit in separate columns.
Check the catalog data before trusting any of it. Variants that share one SKU merge as soon as a spreadsheet or an app matches on SKU, which is why the query groups by variant ID as well. A variant with no cost recorded shows $0 of stock value, so it drops to the bottom of any view sorted by money.

A live store's stock by variant, with one SKU shared across several variants and no cost recorded on others. Unit costs and values are blurred.
For the bottle, the query returned these eight weeks.
|
Week |
Units sold |
Days in stock |
Promotion |
|
Aug 3 |
126 |
7 |
|
|
Aug 10 |
134 |
7 |
|
|
Aug 17 |
121 |
7 |
|
|
Aug 24 |
62 |
3 |
|
|
Aug 31 |
71 |
4 |
|
|
Sep 7 |
129 |
7 |
|
|
Sep 14 |
212 |
7 |
20% off sitewide |
|
Sep 21 |
118 |
7 |
|
|
Total |
973 |
49 of 56 |
How to clean Shopify sales history before forecasting
How to correct sales history for stockouts
Divide by the days the product could be bought.
in-stock daily rate = units sold ÷ days in stock
The bottle sold 973 units in 56 days, but it was only available for 49 of them. Seven days of demand went somewhere else. At the baseline rate worked out below, that is about 127 bottles, or roughly $4,060 in sales at $32 each.
Weekly units for the bottle, with the two short weeks and the promotion week marked.
A stockout does more damage than the missing days suggest, because it usually hits the products that sell fastest. The report then tells you to order less of exactly those.
How to separate promotions from baseline demand
The week of September 14 ran a sitewide 20% discount. Leave it in and the baseline includes demand you paid for with margin. Take the promotion week out of both sides of the division.
|
Reading |
Calculation |
Units per day |
|
What the default report shows |
973 ÷ 56 days |
17.4 |
|
Corrected for stockouts only |
973 ÷ 49 days |
19.9 |
|
Baseline, promotion week removed |
761 ÷ 42 days |
18.1 |
The baseline is 18.1 units a day. The two errors pull in opposite directions and nearly cancel here, which is luck. A product with a stockout and no promotion, or the reverse, carries the full error into the order.
Don't throw the promotion week away. It tells you what a discount does to this product.
promotion lift = promotion units ÷ baseline units for the same number of days
For the bottle that is 212 ÷ 126.7, a lift of 1.67. Keep a running list of these by promotion type and depth. It is the best evidence you have for the next promotion's forecast, and it gets used further down.
The week after the promotion sold 118 against a baseline week of about 127. Some of a promotion's units are next week's sales arriving early, so watch that dip on products people stock up on.
How to account for returns in a demand forecast
Returns don't change what customers wanted. They change how many units you have to buy, because a resellable return goes back on the shelf. Shopify's Quantity sold doesn't net returns out, so a product with a high return rate looks like it is running down faster than it is.
Reported and real run-down for a variant with a 30% return rate.
Only count returns that come back in a condition you can sell. The bottle's resellable return rate is 5%, which comes off at the purchase order stage. For apparel the figure is far larger, and what each return costs decides whether restocking it is worth the handling.
How to add seasonality to a demand forecast
The baseline of 18.1 a day was measured in August and September. The window runs through November and most of December. Carrying a late-summer rate into peak season is the largest single error in the example.
A seasonal index says how each month compares with an average month.
seasonal index = units sold in the month ÷ average monthly units for the year
Build it at product type level, across all bottles, because one variant's history is too thin and has its own stockouts in it. The same dataset returns the last twelve months of units by month and product type.
FROM inventory
SHOW inventory_units_sold
GROUP BY product_type
TIMESERIES month
SINCE -12m UNTIL -1d

Seasonal index for the bottles product type, with the forecast window shaded.
Then four steps:
-
Work out the index of the period the baseline came from. August is 0.99 and September 0.89. Weighted by the 42 days the baseline used, 24 in August and 18 in September, that is 0.95.
-
Divide the baseline by it. 18.1 ÷ 0.95 is 19.1 units a day, the rate for an average month.
-
Multiply 19.1 by each month's index to get that month's daily rate.
-
Multiply by the days of that month inside the window.
|
Month |
Days in window |
Seasonal index |
Units per day |
Units |
|
September |
3 |
0.89 |
17.0 |
51 |
|
October |
31 |
0.94 |
18.0 |
558 |
|
November |
30 |
1.47 |
28.1 |
843 |
|
December |
20 |
1.33 |
25.4 |
508 |
|
Window |
84 |
1,960 |
Step 1 is the one that gets skipped. Multiplying a September baseline straight by November's index assumes September was an average month, and here it wasn't.
A monthly index is coarse around a peak. The window takes only the first 20 days of December and still applies the whole month's index. Events also move between months. Cyber Monday fell on December 1 in 2025 and falls on November 30 in 2026, so last year's December carries a day that belongs to this year's November. For the weeks around Black Friday and Christmas, build the index by week and line the weeks up by the event.
Leave year-over-year growth out. The baseline was measured in the last eight weeks, so this year's growth is already in the 18.1. The index only supplies the shape of the year. Multiply by a growth rate as well and the same growth is in the number twice. We'd take a recent level with last year's shape over any trend line fitted to two years of monthly totals.
A store with less than a year of history has no index of its own. Use the shape of the whole store, or of the closest product type that has a full year, and say so next to the number.
How to add your marketing calendar to the forecast
Everything so far comes from the past. The forecast also needs what you already know about the next 84 days, and the first question for each item is whether last year's numbers already contain it.
|
Planned event |
Already in the index? |
What to do |
|
Black Friday sale at the same depth as last year |
Yes, it is why November reads 1.47 |
Add nothing |
|
A new 5-day early access sale in October at 20% off |
No |
Add baseline × days × (lift − 1) |
|
A deeper or longer sale than last year |
Partly |
Add only the difference in lift |
|
A product launch or restock email to a waitlist |
No |
Add the units from the last comparable send |
|
A wholesale or bulk order you know is coming |
No |
Add the order quantity, and keep past bulk orders out of the baseline. Orders taken outside Shopify draw on the same stock and never appear in this history |
For the bottle, the October sale adds 18.0 × 5 × 0.67, which is 60 units. The forecast for the window is 2,020.
Past bulk orders only come out of the baseline if you can find them. Mark them when they come in, with an order tag or metafield, so their units can be subtracted from the history.
Spend counts as a plan too. A forecast built on last year's shape assumes last year's spending pattern, so if this year's marketing budget by month moves money into October, part of November's demand moves with it. The same goes for channels that have changed since the index was built.
Across 73 stores we manage, orders from AI assistants rose from 5.9 to 16.1 a day in twelve months while visits stayed flat, and no seasonal index from the year before would show that.
This step needs two people. Whoever places the order has to see the promotion calendar before the order goes out, with dates and discount depth.
How to turn a demand forecast into a purchase order
purchase order = demand forecast − resellable returns + safety stock − on hand − on order
The bottle's purchase order, from forecast to cases ordered.
Safety stock is the line people guess, and it stops being a guess once you have measured how wrong your forecasts run.
safety stock = 2 × average absolute forecast error × net units needed
The bottle's last four forecasts missed by 12% on average, in one direction or the other.
Twice that, applied to 1,919 net units, is 461. Two times the average miss covers roughly 95 order cycles in 100 when misses are close to normally distributed around zero. If they lean one way, the bias figure in the accuracy section will show it. Use 2 for A-grade products. For B-grade, 1.3 covers roughly 85 cycles in 100 and ties up less cash.
With no error history yet, start A-grade products at two weeks of cover as a placeholder, and replace it with the measured figure after three order cycles.
This buffer covers demand running above forecast. It does not cover a late shipment, so for a supplier who runs late, add the usual delay to the lead time before working out the window.
Before the order goes out:
-
Round up to the supplier's case pack or minimum. Here 1,140 becomes 1,152, which is 48 cases.
-
Look at when the cash leaves. An 8-week lead time with a deposit means these units are paid for before the season starts, and your cash conversion cycle tells you how long that money stays out.
How to check stock on the day the purchase order arrives
The formula covers the whole window and says nothing about timing inside it. An order can be the right size and still land after the shelf is empty.
stock on arrival day = on hand + on order arriving before then − forecast demand until then
|
Line |
Units |
|
On hand and on order |
1,240 |
|
Forecast demand, September 28 to November 22 |
1,287 |
|
Stock when the order lands on November 23 |
− 47 |
The bottle runs out about two days before the order arrives, in the last days before Black Friday week, and with no safety stock left. The order is the right size and it went out too late.
What can still be done at that point:
-
Ask the supplier to ship part of the order early, or send a first lot by air.
-
Move or shorten the October sale, which uses 60 units.
-
Hold back paid spend on this product in the last week before arrival.
For next year, work backward from the day the stock has to be on the shelf. To land a week before Black Friday week on a 56-day lead time, the order goes out by about September 21, and earlier for a supplier who runs late.
A draft purchase order in Shopify, with the estimated arrival that sets the lead time.
Which demand forecasting method fits which product
The bottle is a steady seller with a full year behind it. Plenty of products aren't, and running the same method on all of them wastes effort on some and misleads on others.
|
Product pattern |
Method |
What to pull |
|
Steady seller, a year or more of history |
In-stock baseline × seasonal index, as above |
The query above, plus last year by month |
|
Sold only part of the year |
Last season's weekly curve, scaled by how this year's first weeks compare |
Last season's units by week |
|
New product, no history |
The launch curve of the closest comparable product. Order small, then check weekly for the first month |
The comparable's first eight weeks |
|
Slow seller, a few units a week |
No forecast. Set a minimum and a maximum and order back up to the maximum |
Units sold in the last 26 weeks |
|
Driven by drops or creator posts |
Forecast the baseline and each event separately |
The lift from past events |
|
Subscription |
Renewals are known demand. For each renewal cycle in the window, the previous cycle's subscribers × (1 − churn rate), plus a forecast for one-time orders |
Active subscriber count by product |
Use Shopify's grades to decide where the effort goes. ABC product analysis grades each variant on its share of revenue over the last 28 days, with A-grade variants making up 80% of revenue. Add AND product_variant_abc_grade = 'A' to the query's WHERE line and forecast those properly each cycle.
C-grade products get the minimum and maximum, or get dropped, because overstock there is cleared at a discount that comes straight out of gross margin.
How to measure demand forecast accuracy
When the window closes, put the forecast next to what sold.
WAPE = sum of absolute errors ÷ sum of actual units
bias = (total forecast − total actual) ÷ total actual
|
Product |
Forecast |
Actual |
Error |
|
Bottle 24 oz, black |
2,020 |
1,890 |
+ 130 |
|
Bottle 24 oz, white |
1,200 |
1,340 |
− 140 |
|
Bottle 32 oz, black |
860 |
790 |
+ 70 |
|
Tumbler 16 oz |
540 |
610 |
− 70 |
|
Lid 3-pack |
300 |
180 |
+ 120 |
|
Total |
4,920 |
4,810 |
Forecast error by product, over and under Units over and under forecast for five products in one window.
|
Measure |
Result |
What it says |
|
WAPE |
11.0% |
The typical miss, weighted by volume |
|
Bias |
+ 2.3% |
The forecasts ran slightly high overall |
|
Average of each product's percentage error |
20.9% |
Inflated by the lid pack, which is 4% of units |
WAPE is the one to track. Averaging percentages lets a small product swing the result. Take the lid pack out and that average falls from 20.9% to 9.4%, while WAPE only moves from 11.0% to 8.9%.
Bias tells you what to fix. A WAPE of 11% with bias near zero means the misses are noise, and safety stock is the right answer to them. The same WAPE with a bias of +11% means every forecast ran high, which points at something in the method, often a promotion left in the baseline or growth counted twice.
To make the score mean something:
-
Correct the actuals too. If a product ran out during the window, its sales understate demand, and a forecast that was too low gets marked as too high. Use the in-stock rate on the actual side as well.
-
Keep the trailing average as a benchmark. For the bottle it said 1,462 against 1,890 actual, a miss of 23%, where the corrected forecast missed by 7%. If your method can't beat the trailing average on your own products, simplify it.
-
Feed the error back. This window's average miss for each product becomes the input to its next safety stock figure.
When to move demand forecasting out of a spreadsheet
Everything above fits in a spreadsheet for a few dozen A-grade variants on one supplier calendar. It starts to fail for reasons that have little to do with forecasting skill:
-
The number of variants worth forecasting outgrows the hours available each order cycle.
-
Stock for the same product sits in more than one place, such as your own warehouse and Amazon FBA, and each place needs its own reorder.
-
Suppliers use different lead times, minimums and case packs, so every row has its own window.
-
Bundles and kits draw on shared components.
Shopify's own tools cover part of this. Stocky, the Shopify app that handled forecasting for retail stores, shut down on August 31, 2026. Purchase orders are in the admin, and Shopify says Sidekick can recommend items to reorder and draft the purchase order. Check a suggestion like that against your own window, season and promotion calendar before it goes to a supplier.
A planning tool applies the same arithmetic as this article to every variant, every day, and its output is only as good as the lead times, minimums and stock counts entered into it.