Trend Lines – How to Add Line of Best Fit in Google Sheets

Visualizing data using charts and graphs can be a great way to understand your data and relationships between the variables in the data.

Moreover, adding a trend line (also called the line of best fit) to the chart can help you gain a deeper understanding of the chart.

In this tutorial I will show you how to add a line of best fit in Google Sheets, to help you gain better insights into your data.

What is a Line of Best Fit, and Why Add a Trendline?

A trend line, or a ‘line of best fit’ is one that is superimposed on a chart to understand trends within the data.

These lines can help you understand the direction of the data, make forecasts and understand relationships between data elements.

For example, if you look at the scatter chart below, you can somewhat tell how the data points are distributed but it’s hard to tell if there’s an upward or downward trend. It is also a little tough to make proper sense of the distribution.

Scatter chart ad vs sales

What happens if I add a trendline to this chart?

Line of Best Fit in scatter chart in google sheets

Adding a trend line, as shown above, helps bring a lot of things into perspective.

We can now see that the data is moving in an upward direction.

We can also extrapolate the line to make predictions about future data points, and I can tell which data points are outliers, or completely far away from the general trend.

Trend lines can be added to bar, line, column, or scatter charts. In the next section I will show you how to add a trendline in Google Sheets to fit with a scatter chart.

How to Add a Line of Best Fit in Google Sheets

Before I show you how to add a line of best fit, let us first quickly go over how you can create a chart for the data shown below:

Dataset to create line of best fit

In the above image, I have data on the number of times ads were posted and the number of sales made.

To visualize this type of data, a scatter chart would be a great option.

Here’s how you can quickly use this data to create a scatter chart in Google Sheets.

Creating a Scatter Chart in Google Sheets

To create a scatter chart based on our given data, follow the steps below:

  1. Select the data range, including the column headers. In our case, select the range A1:B22.
  2. Click on the Insert menu from the menu bar.
Click on Insert
  1. Select the Chart option from this menu.
Click on Chart option in Google Sheets
  1. You will see a chart displayed on the worksheet and a Chart Editor sidebar on the right side of the window.
chart editor of the scatter chart
  1. Google usually attempts to predict and recommend a chart depending on your selected data. If the chart displayed is not a scatter chart, then go to step 6. Otherwise, stop here.
  2. To convert your displayed chart to a scatter chart, select the Setup tab from the Chart Editor and click on the drop-down menu under ‘Chart Type’.
  3. From the chart options, select “Scatter Chart”, which you should be able to find under the Suggested or Other category.
change the chart type to scatter chart

You should now see a Scatter chart on your worksheet. Next, it’s time to add a line of best fit so you can understand the trends in your data.

How to Find the Line of Best Fit on Google Sheets

There is no Google Sheets line of best fit equation you have to use. You just have to make some customizations to the chart.

The Chart editor sidebar consists of two tabs – Setup and Customize. The Customize tab has different options to help you customize different chart settings.

To add a line of best fit to the scatter chart that I created, you need to access this Customize tab. Follow the steps below:

  1. Click on the Customize tab of the Chart Editor.
click on customize in chart editor
  1. Select the Series drop down menu.
click on series in chart editor
  1. If you scroll down the drop down menu, you will see three checkboxes.
three checkboxes in the customize option in chart editor
  1. Select the ‘Trend line’ checkbox.
select the trendline option

This will display a trend line (or line of best fit) across your scatter chart. 

Line of Best Fit in scatter chart in google sheets

In our example, you will notice the trend chart shows an upward trend. That means as the number of ads are increased, sales start going up.

Making Changes to the Trend Line

Now that you know how to find the lineIf you want to further customize the trend line, here’s what you need to do. Under the trend line checkbox, there are a number of options to customize the trend line. For example, you can:

  1. Change the type of trend line. You have the option to select linear, exponential, polynomial, logarithmic, power series, and moving average trend lines.
  2. Change the line color.
  3. Change the opacity and thickness of the trend line.
  4. Change the label for the trend line.
  5. Display the R2 value. This value helps you see how closely the trend line fits the data. The closer this value is to 1, the closer the fit.
Trendline options
  1. If you select Polynomial as your trend line type, you will also get the option to select the polynomial degrees.
select the polynomial degree
  1. If you select Moving Average as your trend line type, you will get the option to select the type of average, i.e. Trailing or Centered. You can also select the number of periods for the Moving Average trend line.
moving average trend line settings

Play around with the different options until you finally obtain a trend line that provides you with enough insight on your data.

Adding Multiple Trendlines in Google Sheets

If your scatter plat has more than one series, you can add a trendline for each set of data. Let’s take a look at an example:

Adding multiple trendlines before image

Say we wanted a trendline for both Product A and Product B. Here’s how you’d do it:

  1. Navigate to Chart editor > Customize > Series
  2. Make sure the drop-down list has Apply to all series selected
  3. Check the Trendline box

Adding multiple trendlines after image

You can also add trendlines to each individual data set instead of all at once by selecting the series from the dropdown menu instead of Apply to all series.

Using the TREND Function to Make a Trendline

The TREND function is used to show forecasting potential future values, but you can also use it as a trendline Google Sheets to make lines of best fit in existing data. It operates under the following syntax:

=TREND(known_data_y, [known_data_x], [new_data_x])

To use it in a data set, you input the know y and x values in the respective places, you’d also provide new x values and it would predict possible new y values based on the existing data. The trick to getting it to work with current values is to use the knows x values as the new_data_x value too. Here’s an example of how to add a best fit line in Google Sheets with the TREND function, let’s say we have the following values in our sheet:

Trend line fingures before

We could substitute the x and y values into the trend function like so:

=TREND(B2:B8,A2:A8,A2:A8)

Note that the know_data_x and new_data_x are the same. It would give the following results:

TREND function - after

You may notice that the trendline figures are increasing at a steady rate instead of sporadically like the initial data. If we were to chart the data it would show a clear trend.

unmarketd trendline thriugh TREND function

Of course, you could then ad a physical line to the data in the same way we did for the other examples.

a full trend line added with the TREND function

This is a convoluted way to build a line of best fit in Google Sheets, and we’d recommend only using the TREND function for forecasting.

How to Insert a Trendline in Google Sheets FAQ

Does Google Sheets Have Line of Best Fit?

Yes, but it’s called a trendline instead,

How Do You Add a Line of Best Fit on Google Sheets? / Can You Add a Trendline in Google Sheets?

Here’s how to make a trendline in Google Sheets.

  1. Open the Chart editor and head to Customize
  2. In the Series tab, check the box that says Trendline.

Is Trendline the Same as Line of Best Fit?

Yes, although some may argue that a line of best fit is only for linear equations, in Google Sheets, they mean the same thing.

Where Is R2 in Google Sheets? / How Do You Find the Slope of a Line of Best Fit In Google Sheets?

Finding the slope in Google Sheets only takes a few clicks.

  1. Navigate to Chart editor > Customize > Series
  2. Make sure Trendline is checked
  3. To show the slope equation, change the Label to Use equation
  4. To show the R2 slope, Check the R2 box

Which Equations Should You Use From the Types Menu?

The equation you select from the Types dropdown menu will affect the shape of the best fit line in Google Sheets. Here’s a brief explanation of each:

  1. Linear: Creates a straight line of best fit from the data points
  2. Exponential: An increase or decrease from the initial data point at an increasing rate.
  3. Logarithmic: A rapidly increasing or decreasing set of data that flattens out over time
  4. Polynomial: For varied data
  5. Power series: For a steady increase or decrease from initial value
  6. Moving average: Smooths out volatile data

There is no bell curve option.

Wrapping Up the Line of Best Fit Tutorial

In this tutorial, I showed you how to add a line of best fit in Google Sheets to analyze and make effective inferences about your data.

The line of best fit (or trend line) can help you observe trends and patterns in your data, can help you understand how closely your data points relate to one another and it can help you identify outliers in the data, which would have been otherwise difficult to find out.

I hope this tutorial was helpful for you.

Other Google Sheets tutorials you may like:

Most Popular Posts

Sumit

Sumit

Google Sheets and Microsoft Excel Expert.

Leave a Comment