Skip to content

FORECAST.LINEAR

Predicts a y value for a given x by fitting a straight line through known pairs of x and y values.

Syntax

=FORECAST.LINEAR(, , )

Statistical

Excel 2016 and later, including Excel for Microsoft 365 and Excel for the web. The older FORECAST function returns the same result in every version.

Try it

Edit the formula in B9 or change the inputs. The sheet recalculates as you type.

B9
A
B
C
1
Month number
Sales
2
1
100
3
2
108
4
3
119
5
4
125
6
5
136
7
6
142
8
9
Forecast for month 7
151.7

B9 =ROUND(FORECAST.LINEAR(7,B2:B7,A2:A7),1) returns 151.7

How FORECAST.LINEAR works

FORECAST.LINEAR fits a straight line through your known data and reads off the y value that the line gives for a new x. It is the quickest way to answer "if we spend 60k on ads, what sales should we expect?" or "what will next month's total be if the trend continues?".

How it works

FORECAST.LINEAR uses least squares, the same fit as SLOPE and INTERCEPT. The prediction is:

intercept + slope × x

so =FORECAST.LINEAR(60, C2:C6, B2:B6) equals =INTERCEPT(C2:C6,B2:B6) + SLOPE(C2:C6,B2:B6) * 60. The function simply does both steps in one.

The argument order

The new x comes first, then the known y values, then the known x values. It is easy to mix up the last two. If you swap them, the prediction answers a different question and no error appears. The y values are what you want to predict; the x values are what drives them.

Forecasting over time

For a time trend, use period numbers 1, 2, 3 ... as x, or the dates themselves. With sales for months 1 to 6, =FORECAST.LINEAR(7, B2:B7, A2:A7) predicts month 7. Dates work as x because they are numbers, so the prediction for a future date is on the same straight line.

Linear forecasts assume the trend continues at the same rate. For seasonal data or curved growth, the line misses patterns. Excel also has FORECAST.ETS for seasonal data, and TREND, which returns predictions for several x values at once.

FORECAST and FORECAST.LINEAR

FORECAST.LINEAR was added in Excel 2016 as the clearer name alongside FORECAST.ETS. The older FORECAST gives identical results and still works. Use FORECAST.LINEAR in new work. If a file must open in Excel 2013 or earlier, use FORECAST.

Errors and limits

  • The two known ranges must have the same number of values, or the result is #N/A.
  • If every known x is the same, the result is #DIV/0!.
  • A non-numeric x returns #VALUE!.
  • Predicting far outside the range of your data is risky, because the line may not hold there. Check how well a straight line fits with CORREL.

Arguments

x
The x value to predict for, such as 7 for the next month or a cell such as B8. It can be a number, date or reference.
known_ys
The y values you already have, such as sales in C2:C6. They come before the x values.
known_xs
The x values paired with them, such as ad spend or period numbers in B2:B6. It must hold the same number of values as known_ys.

Examples

Each example is a live sheet. Change the inputs or the formula and watch the result.

Example 1

Predict next month with a trend

B9 =ROUND(FORECAST.LINEAR(7,B2:B7,A2:A7),1)

Result: 151.7

The trend line adds about 8.57 per month from a starting point near 91.67, so month 7 comes out at about 151.7.

B9
A
B
C
1
Month number
Sales
2
1
100
3
2
108
4
3
119
5
4
125
6
5
136
7
6
142
8
9
Forecast for month 7
151.7

B9 =ROUND(FORECAST.LINEAR(7,B2:B7,A2:A7),1) returns 151.7

Example 2

Predict sales for a planned ad spend

B8 =FORECAST.LINEAR(60,C2:C6,B2:B6)

Result: 260

The line is sales = 92 + 2.8 × ad spend. At 60 the prediction is 92 + 168 = 260.

B8
A
B
C
1
Month
Ad spend (k)
Sales (k)
2
Jan
10
120
3
Feb
20
150
4
Mar
30
170
5
Apr
40
210
6
May
50
230
7
8
Forecast sales at 60k
260
9

B8 =FORECAST.LINEAR(60,C2:C6,B2:B6) returns 260

Example 3

Read x from a cell

B9 =FORECAST.LINEAR(B8,C2:C6,B2:B6)

Result: 162

Change B8 and the forecast follows. At 25, the line gives 92 + 2.8 × 25 = 162.

B9
A
B
C
1
Month
Ad spend (k)
Sales (k)
2
Jan
10
120
3
Feb
20
150
4
Mar
30
170
5
Apr
40
210
6
May
50
230
7
8
Planned ad spend (k)
25
9
Forecast sales (k)
162
10
11

B9 =FORECAST.LINEAR(B8,C2:C6,B2:B6) returns 162

Example 4

Mismatched ranges

B8 =FORECAST.LINEAR(60,C2:C5,B2:B6)

Result: #N/A

The sales range stops one row short of the ad spend range, so the pairs do not line up.

B8
A
B
C
1
Month
Ad spend (k)
Sales (k)
2
Jan
10
120
3
Feb
20
150
4
Mar
30
170
5
Apr
40
210
6
May
50
230
7
8
Forecast
#N/A
9

B8 =FORECAST.LINEAR(60,C2:C5,B2:B6) returns #N/A

Your turn.

Solve it in the sheet. Every answer is checked, with hints if you need them.

Task 1 of 2

In B10, forecast the visits for the week number in B9, using a straight-line trend.

Answer in B10.

B10
A
B
C
1
Week
Visits
2
1
1,200
3
2
1,260
4
3
1,340
5
4
1,380
6
5
1,450
7
6
1,520
8
9
Week to forecast
7
10
Forecast visits
11
Weeks 7 and 8 together
12

Common mistakes

  • The order is x, then known_ys, then known_xs. Mixing up the last two returns a different number with no error.
  • The known ranges must be the same size, or the result is #N/A.
  • A straight line assumes the trend continues unchanged. Seasonal or accelerating data needs another method, such as FORECAST.ETS.
  • Forecasting far beyond your data, or backwards a long way, is extrapolation and can be badly wrong. Keep x close to the range you have.
  • If x is a date, the line is fitted on date numbers, so predictions for dates work, but the slope is per day.
  • Text, blanks and logical values in the known ranges are dropped in pairs.

Questions people ask

What is the difference between FORECAST and FORECAST.LINEAR?

They return the same result. FORECAST.LINEAR is the newer name from Excel 2016, and FORECAST is kept for compatibility.

How do I forecast next month in Excel?

Number your periods 1, 2, 3 ... and use `=FORECAST.LINEAR(7,B2:B7,A2:A7)` to predict period 7. For seasonal data, FORECAST.ETS is usually better.

Why does FORECAST.LINEAR return #N/A?

The known_ys and known_xs ranges have different numbers of values. Make them the same size.

How accurate is a linear forecast?

It depends on how straight the data is. A correlation (CORREL) close to 1 or -1 means a line fits well. Even then, the further you predict from your data, the less you can rely on it.

Learn FORECAST.LINEAR in a real sheet.

Tracks take you from the basics to modelling, one graded exercise at a time.