Skip to content

SLOPE

Returns the slope of the straight line that best fits your data: how much y changes for each one-unit increase in x.

Syntax

=SLOPE(, )

Statistical

All versions of Excel, including Excel for Microsoft 365 and Excel for the web.

Try it

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

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
Slope
2.8
9

B8 =SLOPE(C2:C6,B2:B6) returns 2.8

How SLOPE works

SLOPE fits a straight line through your data using least squares and returns its gradient. The slope is the answer to "for every extra unit of x, how much more y do we get?". It turns a scatter of points into a rate: sales per advertising pound, cost per kilometre, or units gained per month.

The argument order

SLOPE takes y first, then x: =SLOPE(known_ys, known_xs). The y values are the thing you are explaining, such as sales, and the x values are what you think drives it, such as ad spend. This is the reverse of what many people expect, and swapping them returns a different number without any error.

Ad spend of 10, 20, 30, 40 and 50 against sales of 120, 150, 170, 210 and 230 gives =SLOPE(C2:C6, B2:B6) = 2.8. Each extra unit of ad spend goes with about 2.8 more units of sales. Swapped, =SLOPE(B2:B6, C2:C6) returns about 0.35, which answers a different question: how much ad spend goes with a one-unit rise in sales.

What the sign means

A positive slope means y rises with x. A negative slope means y falls as x rises, such as units sold against price. A slope near zero means the best-fit line is nearly flat, so x tells you little about y.

Trends over time

Use time as x to get the average change per period. For months numbered 1 to 6, =SLOPE(B2:B7, A2:A7) returns the average monthly change in the series. If your x values are dates, the slope is the change per day, so multiply by 30 or 365 for a monthly or yearly figure.

Behind the scenes

The slope equals the correlation multiplied by the ratio of the spreads: CORREL(y,x) × STDEV.S(y) / STDEV.S(x). SLOPE and INTERCEPT together define the line y = intercept + slope × x. FORECAST.LINEAR uses both to predict a value for a new x. CORREL tells you how well the line fits.

Errors

The two ranges must have the same number of values, or SLOPE returns #N/A. If every x value is identical, the line is vertical and SLOPE returns #DIV/0!. Text, blanks and logical values in either range are dropped in pairs. A slope describes a straight-line fit only; check a chart before using it on curved data.

Arguments

known_ys
The dependent values, the ones you want to explain or predict, such as sales in C2:C6. This comes first.
known_xs
The independent values, the ones that drive the change, such as ad spend 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

Sales per unit of ad spend

B8 =SLOPE(C2:C6,B2:B6)

Result: 2.8

Sales is y and ad spend is x. Each extra unit of ad spend goes with 2.8 more units of sales on the best-fit line.

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
Slope
2.8
9

B8 =SLOPE(C2:C6,B2:B6) returns 2.8

Example 2

Swapping the arguments answers a different question

B8 =ROUND(SLOPE(B2:B6,C2:C6),3)

Result: 0.354

With the arguments swapped, the slope is ad spend per unit of sales. It is not the reciprocal of 2.8, because the fit is not perfect.

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
Swapped slope
0.354
9

B8 =ROUND(SLOPE(B2:B6,C2:C6),3) returns 0.354

Example 3

A negative slope

B8 =SLOPE(C2:C6,B2:B6)

Result: -10

Each 1 increase in price goes with 10 fewer units sold.

B8
A
B
C
1
Week
Price
Units sold
2
W1
5
100
3
W2
6
90
4
W3
7
80
5
W4
8
70
6
W5
9
60
7
8
Slope
-10
9

B8 =SLOPE(C2:C6,B2:B6) returns -10

Example 4

Average monthly change

B9 =ROUND(SLOPE(B2:B7,A2:A7),2)

Result: 8.57

Using the month number as x, the trend line adds about 8.57 to sales each month.

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
Change per month
8.57

B9 =ROUND(SLOPE(B2:B7,A2:A7),2) returns 8.57

Your turn.

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

Task 1 of 2

In B8, return how much the delivery cost rises, on the best-fit line, for each extra kilometre.

Answer in B8.

B8
A
B
C
D
1
Distance (km)
Delivery cost
2
10
18
3
20
27
4
30
41
5
40
48
6
50
62
7
8
Cost per km
9
Extra cost for 15 km
10

Common mistakes

  • The order is y first, then x: SLOPE(known_ys, known_xs). Swapping them returns a different number with no error.
  • The two ranges must be the same size. Otherwise SLOPE returns #N/A.
  • If every x value is the same, the slope is undefined and SLOPE returns #DIV/0!.
  • Text, blanks and logical values are dropped in pairs. Numbers stored as text are skipped without warning, which can leave fewer points than you expect.
  • SLOPE fits a straight line. If the data curves, such as growth that accelerates, the slope is only a rough average. Check a chart.
  • When x is a date, the slope is the change per day. Multiply to get a monthly or yearly rate.

Questions people ask

Which argument comes first in SLOPE?

The y values, the ones you want to explain. `=SLOPE(sales, ad_spend)` gives the change in sales per unit of ad spend. Swapping them gives the reverse relationship.

What does a negative slope mean?

y falls as x rises. For example, units sold fall as the price increases.

How do I get the slope of a trend over time?

Use a period number or a date as x. `=SLOPE(B2:B13,A2:A13)` with dates in column A gives the average change per day. Multiply by 30 for a rough monthly figure.

How is SLOPE related to the line on a chart?

It is the same number as the slope of a linear trendline. Use INTERCEPT for where that line crosses the y axis.

Learn SLOPE in a real sheet.

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