When working with graphs or charts in excel, you may need to add a line to visualize the general trend in your data. This line is created based on certain equations. In this article, we will learn how to find the equation of a line in excel.
Download Practice Workbook
Download this sample file and try it yourself.
What Is Trendline in Excel?
Theoretically, a trendline is a linear or curved line in a graph or chart that defines the general pattern of the selected dataset. It is also referred to as the line of best fit. The trendline is widely used for showing data movements over a certain period of time. It also shows the interrelation between two variables.
The trendline only connects general data points in the chart, not all points ignoring errors and exceptions. It is also used for forecasting.
Step by Step Process to Find the Equation of a Line in Excel
Now, let’s get into the main part of our article. Following is the step-by-step process for finding the equation of a line. So, without any delay, let’s begin the process.
Step 1: Prepare Dataset
For describing the process, create a dataset with the information of Item Name, Sold Items and Sales amount for 6 types of fruits.
Here the values in columns C and D will act as Y and X axis respectively.
Step 2: Create a Scatter Chart
Now, we will create a chart out of the dataset. Simply follow the process below:
- First, select cell range C5:D10.
- Then, go to the Insert tab and select Scatter Chart from the Charts group.
- Following, choose Scatter from the options.
- That’s it, you will see the chart on your worksheet.
Step 3: Add Trendline to the Chart
So as we have our chart, let us insert a trendline based on the dataset.
- In the beginning, select the chart.
- Then, click on the Plus (+) icon defining Chart Elements.
- Now, mark the Trendline option from the Context Menu.
- Finally, you will see a trendline has appeared on the chart.
- After some formatting, the trendline looks like this:
Step 4: Find the Equation of the Line
Now comes the stage where we will find the equation of this line. Let’s see how it works.
- First, select the line on your chart.
- Then, right-click on it and choose Format Trendline.
- Following, you will be directed to the Format Trendline panel on the right.
- Here, mark checked the Display Equation on chart box.
- That’s it, we can visualize the equation beside the line now.
Step 5: Add Decimal Places to the Equation
For further understanding, let us add decimal places to the values in the equation.
- Firstly, select the trendline again.
- Secondly, right-click on it and select Format Trendline Label from the Context Menu.
- Thirdly, select Number from the Category list in the Format Trendline Label panel.
- Following, insert your required value in the Decimal places box.
- Lastly, you will see decimal points have increased in the line equation.
How to Find Slope of Line Equation in Excel
To get the slope of the equation, Microsoft Excel has benefitted us with the SLOPE function. Let’s try this function and find out the value of the slope.
- First, select cell C12 on your worksheet.
- In this cell, insert this formula.
- After this, press Enter.
- That’s it, you will see the value of the slope for the line in excel.
Here, we used the SLOPE function to calculate the rate of change between dependent and independent variables. According to the dataset, cell range D5:D10 defined the dependent data points placed on the Y axis. On the other hand, cell range C5:C10 acts as the independent data points plotted on the X axis.
Concluding this article with the hope that it was a helpful one for you on how to find the equation of a line in excel with quick steps. Let us know your insightful suggestion in the comment box. Keep an eye on ExcelDemy for more excel blogs.