1. Home
  2. Blog
  3. ERP

ERP

How to Do Demand Forecasting: Moving Average, Exponential Smoothing, Seasonality and Error Metrics Guide

How to do demand forecasting: moving average, exponential smoothing, seasonality, MAE and MAPE, and how forecast error sets safety stock, with worked examples.

Contents 14 sections
  1. What Is Demand Forecasting and Why Do You Need It?
  2. How Do You Prepare the Data Before Forecasting?
  3. How Is a Moving Average Calculated?
  4. How Does Exponential Smoothing Work?
  5. Error Metrics: How Are MAE, MAPE and Bias Calculated?
  6. How Is Seasonality Calculated?
  7. How Does Forecast Error Determine Safety Stock?
  8. How Much Does Stock Cost Change if Forecast Error Falls by 40%?
  9. Why Does a Forecast Drift, and How Do You Track It?
  10. How Do You Forecast Demand for a New Product?
  11. How Do You Do Demand Forecasting in Six Steps?
  12. What Are the Common Mistakes in Demand Forecasting?
  13. Demand Data and Planning Software with İnovabil
  14. Frequently Asked Questions

Dealer orders rise and fall month to month, and the warehouse is either out of stock or overflowing. More often than not the problem is not the people but the fact that one number about the future was never written down. The answer to how to do demand forecasting is not a sophisticated AI model; it is clean data, a simple method, measuring the error, and tying the forecast to your stock and production plan.

In this guide we take 12 months of sales for a single product group in a dealer portal and calculate a moving average and exponential smoothing by hand, compare the error metrics (MAE, MAPE and bias), build a seasonality index, derive safety stock from the forecast error, and show how to run forecasting in six steps. All figures are representative; they are not measurements from a real business or an industry average.

Key takeawayA good forecast is not one that is never wrong; it is one whose error you know. You cannot pick a method without measuring error, and you cannot compute safety stock without knowing it. A forecast is worth what it adds to your stock and production decisions.

What Is Demand Forecasting and Why Do You Need It?

Demand forecasting is estimating, as a number, how much will sell in a future period from past sales data and known factors such as promotions, seasons and new products. Its output is not a "certain result" but an expectation you can plan against.

A forecast feeds three decisions: how much to order (inventory tracking), how much to produce (production planning) and how large a safety margin to hold. Without a forecast these decisions fall back on gut feeling, and gut feeling drifts in one direction in a systematic way.

MethodWhen it fitsWeak point
Moving averageDemand is flat and data is shortMisses trend and seasons, lags behind
Exponential smoothingYou want recent months to weigh moreLags behind a trend with a small alpha
Seasonality indexA pattern repeats within the yearNeeds at least one, ideally several, years of data
Similar product (analog)New product with no historyDepends on the similarity assumption

How Do You Prepare the Data Before Forecasting?

Sales are not demand. Sales fall when stock runs out, balloon during promotions and shift with returns and cancellations. A forecast should rest on "clean demand", not on raw sales.

  • Correct for out-of-stock days: If a product was out of stock for 12 of 30 days and 72 units sold, the in-stock rate over 18 days is 72 ÷ 18 = 4 units a day. Corrected demand is 4 × 30 = 120 units; the raw 72 understates demand by 40%.
  • Strip out promotions: Record promotion effects separately from base demand; otherwise your future forecast inflates as if a promotion were still running.
  • Separate cancellations and returns: Use units actually kept (order management system).
  • Choose the unit and level: Units or revenue, product or product group, week or month? As a rule, forecast at the level where the planning decision is made.
  • Set the horizon: The horizon must be at least as long as the lead time; a one-month forecast does not cover a two-month supply lead time.
We recommend reading: How to track inventory: a six-lesson practical guide

How Is a Moving Average Calculated?

A moving average takes the forecast for the next month as the average of the last N months. In our example N = 3, so next month is the average of the previous three months.

Example: 12 months of sales (units) for a product group in a dealer portal: 100, 108, 104, 112, 120, 116, 124, 118, 126, 132, 128, 136. The forecast for month 4 is (100 + 108 + 104) ÷ 3 = 104. For month 5 it is (108 + 104 + 112) ÷ 3 = 108. For month 13 it is (132 + 128 + 136) ÷ 3 = 132 units.

How Does Exponential Smoothing Work?

Exponential smoothing builds the next forecast as: new forecast = α × latest actual + (1 − α) × previous forecast. Alpha (α) lies between 0 and 1; a larger α trusts the latest month more.

In the example α = 0.3 and the first forecast is set equal to the first actual (100). The month 2 forecast is 100. Month 3 is 0.3 × 108 + 0.7 × 100 = 102.4; month 4 is 0.3 × 104 + 0.7 × 102.4 = 102.88; month 5 is 0.3 × 112 + 0.7 × 102.88 = 105.62. The month 13 forecast is 127.95 units. Choose alpha by back-testing, not by guessing: in the example, α = 0.5 gives an MAE of 6.51 over the same period, while α = 0.3 gives 9.28.

Error Metrics: How Are MAE, MAPE and Bias Calculated?

Error = actual − forecast. MAE is the average absolute error (in units), MAPE is the average of absolute error divided by actual (in percent), and bias is the signed average of the error. If bias is far from zero, the forecast is drifting in the same direction every time.

The table below compares both methods for months 4–12; because the moving average has no forecast for the first three months, the common comparison uses this period.

MonthActualAvg. forecastErrorError %Smoothing forecastErrorError %
4112104.008.007.14102.889.128.14
5120108.0012.0010.00105.6214.3811.99
6116112.004.003.45109.936.075.23
7124116.008.006.45111.7512.259.88
8118120.00−2.001.69115.432.572.18
9126119.336.675.29116.209.807.78
10132122.679.337.07119.1412.869.74
11128125.332.672.08123.005.003.91
12136128.677.335.39124.5011.508.46

For the moving average, absolute errors sum to 60.00 and signed errors to 56.00. MAE = 60 ÷ 9 = 6.67 units, MAPE = 5.40%, and bias = 56 ÷ 9 = +6.22 units. For exponential smoothing, MAE = 9.28, MAPE = 7.48% and bias = +9.28 (every error is positive, so MAE and bias are equal; because the table is rounded to two decimals, the totals can differ by a hundredth).

On the same data, moving average MAPE is 5.4 percent and exponential smoothing 7.5 percent; both have positive bias, so the forecast sits below actual demand
Error metrics of two methods on the same data.

Two conclusions follow. First, on this series the moving average misses by less. Second, and more important, both have positive bias: the series is rising and both methods lag behind it, so the forecast stays below actual demand. That is a signal to "change the method or add a trend". Remember MAPE's weak point too: when the actual approaches zero the percentage blows up, so MAE is more reliable for low-volume items. For deciding which measures belong on a dashboard, see our KPI guide.

How Is Seasonality Calculated?

A seasonality index is found by dividing a month's sales by the monthly average for the year; above 1.00 is a month above average, below is a month below. The index reveals the swings a flat average hides.

A seasonal product group sold 1,200 units over 12 months last year, an average of 100 a month. June is 130, so its index is 130 ÷ 100 = 1.30; July is 150, index 1.50. If you expect 10% growth next year, the annual forecast is 1,320 and the monthly base is 110. Monthly forecast = base × index.

MonthLast yearIndexForecast (110 × index)
January700.7077
February700.7077
March800.8088
April900.9099
May1101.10121
June1301.30143
July1501.50165
August1401.40154
September1101.10121
October900.9099
November800.8088
December800.8088
Total1,20012.001,320

If you had used a flat 110 and the pattern repeats exactly, you would plan 165 − 110 = 55 units (33%) too few in July and 110 − 77 = 33 units (43%) too many in January; the 12-month mean absolute error would be 308 ÷ 12 ≈ 25.7 units. With a single year of data the index also carries that year's unusual events; wherever possible average two or three years and strip out any unusual month.

How Does Forecast Error Determine Safety Stock?

Safety stock = z × σ_error × √lead time. σ_error is the spread of the monthly forecast error, lead time is in months, and z is the coefficient for your service level. For a 95% service level, z = 1.65 is the commonly used value.

In the example, the root mean square error (RMSE) of the moving average is √(Σ error² ÷ 9) = 7.34 units; because bias persists, we use RMSE as the measure of spread. With a lead time of 2 months:

  • Safety stock = 1.65 × 7.34 × √2 = 17.1 units.
  • Reorder point = expected demand over lead time + safety stock = 2 × 132 + 17.1 = 281.1 ≈ 281 units.

The formula says two things: the bigger the error, the bigger the safety stock, and as lead time grows the buffer grows with its square root. If the forecast is poor, the shelves are "insured" with extra stock; if it is good, the same service level needs less. The calculation can run automatically inside an ERP.

How Much Does Stock Cost Change if Forecast Error Falls by 40%?

Safety stock is proportional to error, so a 40% reduction in error cuts safety stock by 40%: σ_error falls from 7.34 to 4.40. The assumptions below are representative: unit cost ₺1,200, annual holding cost 25%, and 40 product groups with the same structure.

ItemTodayError down 40%
σ_error (units/month)7.344.40
Safety stock (units), z = 1.65, 2 months17.110.3
Stock value, one group₺20,520₺12,360
Stock value, 40 groups₺820,800₺494,400

The difference is 6.8 units per group, or ₺8,160; across 40 groups it is ₺326,400. At a 25% annual holding cost the yearly saving is ₺326,400 × 0.25 = ₺81,600. The service level stays the same; you were previously giving the same assurance with more capital. Compare the cost of a forecasting project with this saving, and bring in the capacity and lot-size calculations from our production planning guide for real line items.

Why Does a Forecast Drift, and How Do You Track It?

There are two kinds of deviation: random (noise) and systematic (bias). Safety stock covers random deviation; systematic deviation is fixed by correcting the method or the data. To tell them apart, use a tracking signal: cumulative error ÷ MAE.

MonthCumulative errorCurrent MAETracking signal
48.008.001.00
830.006.804.41
1256.006.678.40

The signal should hover around zero. In practice ±4 is a commonly used warning threshold; in the example it is crossed in month 8, and because the error keeps going the same way, it shows the method needs another look.

Promotions and exceptions

If a past promotion leaks into base demand, it inflates the future. Example: base demand 120, promotional month 156 (+30%). If the last three months are 120, 156 and 124, the average is 400 ÷ 3 = 133.3; with the promotional month pulled down to 120 it is 364 ÷ 3 = 121.3, a gap of 12 units, or 9.9%. The method: record the promotion separately, forecast base demand, and if the promotion will repeat, apply a separate multiplier (1.30 in the example). Also tag exceptions such as a one-off large order and keep them out of the average. To see sales against forecast on one screen, our business intelligence guide helps.

How Do You Forecast Demand for a New Product?

For a product with no history, you scale the early-month sales pattern of a similar product, then update the scale as real data arrives.

  1. Pick the similar product: Price range, customer base and channel should be close. Example: the similar product's first six months: 40, 55, 65, 70, 72, 74.
  2. Set the scale: If you assume the new product will sell 60% as much, the forecast is 24, 33, 39, 42, 43.2 and 44.4.
  3. Update with actuals: If the first two months come in at 30 and 38, the ratios are 30 ÷ 24 = 1.25 and 38 ÷ 33 = 1.15; the average ratio is 1.20. The month 3 forecast rises to 39 × 1.20 = 46.8 ≈ 47.

In the early months hold a higher safety stock; as data builds up, move to the methods above.

How Do You Do Demand Forecasting in Six Steps?

Set forecasting up not as a calculation done once and left, but as a loop repeated every month.

Six steps of demand forecasting: goal and horizon, prepare data, choose method, back-test, link to plan, track and update
The six steps of demand forecasting.
  1. Goal and horizon: For which decision, at which level, and how many months ahead?
  2. Prepare the data: Correct out-of-stock days, promotions, returns and cancellations.
  3. Choose the method: An average for a flat series, a trend method for a rising one, a seasonality index for a repeating pattern.
  4. Back-test: Forecast the last 9–12 months and compute MAE, MAPE and bias; choose alpha and the window with this test.
  5. Link to the plan: With the forecast and σ_error, compute safety stock, the reorder point and the production plan.
  6. Track and update: Each month compare forecast and actual, check the tracking signal, and change the method when needed.
We recommend reading: How to do inventory counting. If recorded stock is wrong, the forecast is fed with wrong data too.

What Are the Common Mistakes in Demand Forecasting?

  • Treating sales as demand: Not correcting out-of-stock days makes demand look smaller.
  • Not measuring error: Without MAE and bias you cannot tell which method is better.
  • Ignoring bias: A forecast that always misses in the same direction is a system error, not noise.
  • Not linking the forecast to the plan: If a forecast does not turn into safety stock and reorder points, it stays a report.
We recommend reading: What is a data warehouse? A way to keep several years of sales data in one place for analysis.
We recommend reading: What Is Supply Chain Management?
We recommend reading: How to Do Sales Forecasting: Pipeline, Historical Conversion, Accuracy and Forecast Range Guide
We recommend reading: What Is a Manufacturing Execution System (MES)? Shop Floor Tracking, Work Order Records, Downtime Codes and OEE Guide
We recommend reading: How to Manage Multi-Warehouse Inventory: Transfers, In-Transit Stock and Rebalancing Guide
We recommend reading: What Is Price Optimization and Dynamic Pricing? Elasticity, Margin Floor, Rules and Testing Guide
We recommend reading: What Is Shift and Workforce Scheduling Software? Hours Needed, Rules Engine, Skills and Payback Guide
We recommend reading: What Is Production Capacity Planning and Bottleneck Analysis? Effective Capacity, Load Ratio and Lead-Time Guide
We recommend reading: What Is Contact Center Software? Agent Staffing, Queues and the Erlang C Calculation
We recommend reading: How to Calculate Available to Promise (ATP) and Delivery Dates: A Guide to CTP, Capacity and On-Time Promising
We recommend reading: How to Calculate Safety Stock and Reorder Point: Formula, z Value, EOQ and Worked Example
We recommend reading: What Is Vendor-Managed Inventory (VMI)? Min–Max Levels, Replenishment Proposals and Payback Guide
We recommend reading: Make to Order vs Make to Stock: How to Choose (Decoupling Point, Hybrid Strategy and Cost Guide)
We recommend reading: How to Prepare an E-Commerce Store for Peak Campaign Season: Demand, Stock, Capacity and Live Control Guide
We recommend reading: How to Manage Spare Parts Inventory: Intermittent Demand, Critical Parts and Stock Levels Guide
We recommend reading: How to Manage Slow-Moving and Dead Stock: Aging, Classification, Clearance and Decision Guide

Demand Data and Planning Software with İnovabil

At İnovabil our focus is building software from scratch, specific to each company; ERP, integration and custom software are parts of it. We developed logistics and shipment planning with wholesale order management for Karyak, shipment planning for Bofigo and a warehouse management system for Sleepy, and we worked on the purchasing side for Avcılar İnşaat and İZBAN. We do not claim a forecasting module; we suggest clarifying together, in the requirements stage, where order, stock and purchasing data will be collected, at which level it will be monitored and how the forecast will tie into the plan.

Briefly write where your sales data lives and which decision you want to improve, and we will produce the scope as a written analysis. We describe how we work on our process page; for solutions see our custom software service.

Frequently Asked Questions

How do you do demand forecasting?

Clean the data of out-of-stock days and promotion effects, choose a simple method (moving average, exponential smoothing, seasonality index), back-test it on past months and measure the error, then tie the forecast to safety stock and the reorder point and track it every month.

What is the difference between a moving average and exponential smoothing?

A moving average weights the last N months equally; exponential smoothing gives more weight to recent months and exponentially less to older ones. In the example the moving average had a MAPE of 5.40% against 7.48% for exponential smoothing at α = 0.3; alpha is chosen by back-testing.

What do MAE, MAPE and bias mean?

MAE is the average absolute error (in units), MAPE is the average of that error relative to actual demand (in percent), and bias is the signed average of the error. If bias is far from zero, the forecast drifts in the same direction every time.

How is safety stock calculated from forecast error?

Safety stock = z × σ_error × √lead time. For a 95% service level z = 1.65. In the example, with σ_error of 7.34 and a 2-month lead time, 1.65 × 7.34 × √2 ≈ 17.1 units; if error falls 40%, it drops to 10.3 units.

How do you forecast demand for a new product without history?

Scale the early-month sales pattern of a similar product and update the scale as real sales arrive. In the example, starting at 60% scale and finding an average ratio of 1.20 over the first two months lifted the month 3 forecast to 47 units. Hold a higher safety stock in the early months.

Let's talk about your project

Tell us briefly about the software you have in mind; we'll listen and prepare a tailored roadmap and proposal.

Get a quote