Linear regression to forecast sales in Excel
Linear regression draws the straight line that best follows your sales week by week; in Excel you get it with SLOPE (how much it rises or falls per week) and INTERCEPT (where it starts), and FORECAST.LINEAR gives you the value of a future week. It works when sales rise or fall steadily; in a bakery it misleads with the weekday pattern and with special dates.
Updated: 2026-11-27
The steps
- 1. Put the week number (1, 2, 3...) in column A and that week's sales in column B.
- 2. The slope says how many pesos the line rises (or falls, if negative) each week: =SLOPE(B2:B7,A2:A7).
- 3. The intercept says where the line is in week 0, the one before your first data point: =INTERCEPT(B2:B7,A2:A7). It is not a real sale, it is the starting point of the line.
- 4. The forecast of a week is intercept + slope × week number. In Excel, for week 7: =FORECAST.LINEAR(7,B2:B7,A2:A7).
- 5. Check that these are the function names in your version of Excel (in a Spanish Excel they are PENDIENTE, INTERSECCION.EJE and PRONOSTICO.LINEAL); if your Excel asks for a semicolon between the arguments, change it.
An example (invented numbers)
| Week (x) | Sales in $ (y) | x − 3.5 | y − 43,333.33 | Product of the two | (x − 3.5) squared |
|---|---|---|---|---|---|
| 1 | 41,000 | −2.5 | −2,333.33 | 5,833.33 | 6.25 |
| 2 | 42,500 | −1.5 | −833.33 | 1,250.00 | 2.25 |
| 3 | 42,000 | −0.5 | −1,333.33 | 666.67 | 0.25 |
| 4 | 44,000 | 0.5 | 666.67 | 333.33 | 0.25 |
| 5 | 44,500 | 1.5 | 1,166.67 | 1,750.00 | 2.25 |
| 6 | 46,000 | 2.5 | 2,666.67 | 6,666.67 | 6.25 |
| Total | 260,000 | 16,500.00 | 17.50 |
These are invented sales. The average of the weeks (x) is 21 over 6 = 3.5 and that of the sales (y) is 260,000 over 6 = 43,333.33. Slope = total of “Product of the two” over total of “(x − 3.5) squared” = 16,500 over 17.5 = 942.86 pesos per week. Intercept = 43,333.33 − 942.86 × 3.5 = 43,333.33 − 3,300 = 40,033.33. Forecast of week 7 = 40,033.33 + 942.86 × 7 = 40,033.33 + 6,600 = 46,633 pesos. For comparison: copying last week would give 46,000 and the average of the last 4 weeks, 176,500 over 4 = 44,125. The line gives more because it follows the rise; if the rise stops, the line keeps climbing and overshoots more and more, whereas copying last week does not.
When a straight line misleads a bakery
- Weekday pattern: a weekly total hides that Saturday sells differently from Tuesday. To bake, fit one line per day (Saturdays with Saturdays) and per product.
- Special dates: a week with 14 February, 10 May or Day of the Dead pulls the line up, and the following week does not follow it. Set them aside.
- Plateau: if sales stopped rising, the line keeps rising; in the example it would say 47,576 for week 8, even if sales had stayed at 46,000.
- Little data: with 6 weeks, a single odd data point changes the slope a lot.
- Sold-out days: what sold is not the demand if the product ran out early.
- Extending the line many weeks ahead is guessing: use it for one or two weeks, and compare it with your real sales.
How Hornada does it
Hornada forecasts each product for each day from the same weekday of recent weeks, with more weight on the recent ones, and learns the special dates from your history. The line in this guide is something you can build yourself in Excel; it is not a description of Hornada's calculation.
Frequently asked questions
What happens if the slope comes out negative?
That sales over those weeks are falling on average; check whether it was a streak, a special date or a real change before baking less.
Does it work to forecast a single day?
Yes, and it suits better: use only the Saturdays, for example, with the Saturday number in column A.
How many weeks do I need?
You can calculate it with 4 to 8 weeks, but with few the line changes a lot with one data point; always compare it with copying last week.