In this article, we will learn to calculate the slope in Excel.
Finding slope using Excel function
Les us try to calculate the slope using simple formula’s by using the coordinates of 2 points. First write the coordinates of 2 points:
Calculate difference beteween x coordinates: C5-C4
The result is 2 in this example.
Now let us calculate difference between y coordinates: D5-D4
The result is 2 again.
Slope will be difference of Y coordinates divided by difference of X coordinates:
The Slope here is 1.
This was very simple approach, now we will do the same by using the slope function inbuilt in Excel:
The SLOPE function syntax has the following arguments:
- Known y’s Required. An array or cell range of numeric dependent data points.
- Known x’s Required. The set of independent data points.
See in this example as we are typing the formula it is being guided by Excel with the comments below. The slope formula written as SLOPE(KNOWN Y’S,KNOWN X’S)
So the formula will be:
The final contents in the sheet with results is like:
Please find attached the Excel file for reference.
Using LINEST function
Another method to calculate the slope in Excel is to use the LINEST function. This function returns an array of values that includes the slope, intercept, and other regression statistics.
Here are the steps to follow:
- Enter your data into two columns in Excel, with the X-values in one column and the Y-values in another column.
- Select a range of cells where you want to display the slope and intercept results. You will need two cells for the intercept and slope values.
- Type “=LINEST(” in the first cell and select the range of Y-values, followed by a comma.
- Select the range of X-values and type “,TRUE,TRUE)”.
- Press “Ctrl+Shift+Enter” to calculate the LINEST function as an array formula.
Here’s an example formula:
=LINEST(B2:B10, A2:A10, TRUE, TRUE)
In this formula, the range B2:B10 represents the Y-values, and the range A2:A10 represents the X-values. The “TRUE,TRUE” arguments at the end of the formula indicate that you want to include the intercept and regression statistics in the output.
The LINEST function will calculate an array of values that includes the slope in the first cell of the range you selected, and the intercept in the second cell. To display only the slope, use the INDEX function to extract the first value from the LINEST array.
Here’s an example formula to extract the slope:
=INDEX(LINEST(B2:B10, A2:A10, TRUE, TRUE),1)
This formula will return only the slope value.
Finding slope from the chart
There is no need to use slope formula to find the slope. Sometimes it might be possible to find it from the graph.
Lets assume we have such data.
There is a measurement of some value. And you need to find the slope for the value. How to do that?
First plot the line chart for that. Go to Insert – Line Chart.
You can see the simple chart.
Right click the line and choose Add Trendline.
Menu pops in the right side of your screen. Choose “Display Equation on the Chart”.
And here is your slope.
Can’t you see that? If you forgot I will remind.
The equation of the trendline comes from the y = f(x) = ax + b
In this example y = 2.4706x – 10.941
a = 2.4706 and b = -10.941
a = slope = 2.4706
Note: b is the point where the line cross the horizontal line for x=0 point.
To continue pls check how to insert Slope Graph tutorial.