How To Add Trendline in Excel Chart Excel Trendline Types, Equations and Formulas

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 31
At a glance
Powered by AI
The key takeaways are that a trendline shows the general trend in data and can be used to forecast trends. Excel supports adding trendlines to various chart types like scatter, line, column and bar charts.

To add a trendline in Excel, select the chart, click the Chart Elements button, and check the Trendline box or select a trendline type from the dropdown.

The different types of trendlines in Excel are linear, exponential, logarithmic, polynomial, power and moving average.

How to add trendline in Excel chart

Excel trendline types, equations and formulas

 Excel trendline types


o Linear
o Exponential
o Logarithmic
o Polynomial
o Power
o Moving average
 Excel trendline equations and formulas
 Excel trendline equation is wrong - reasons and fixes
When plotting data in a graph, you may often want to visualize
the general trend in your data. This can be done by adding a
trendline to a chart. Luckily, Microsoft Excel has made
inserting a trend line very easy, especially in newer versions.
Nevertheless, there are a few little secrets that make a big
difference, and I will share them with you in a moment.

 Excel chart trendline


 How to add trendline in Excel
 How to insert multiple trendlines in the same chart
 How to format a trendline
 Extend a trendline to forecast future or past trends
 Excel trendline equation
 Find the slope of a trendline
 How to remove a trendline from a chart
Trendline in Excel
A trendline, also referred to as a line of best fit, is a straight
or curved line in a chart that shows the general pattern or
overall direction of the data.
This analytical tool is most often used to show data
movements over a period of time or correlation between two
variables.
Visually, a trendline looks somewhat similar to a line chart, but
it doesn't connect the actual data points as a line chart does.
A best-fit line shows the general trend in all the data, ignoring
statistical errors and minor exceptions. In some cases, it can
also be used to forecast trends.

Excel graphs that support trendlines


A trendline can be added to a variety of Excel charts,
including XY scatter, bubble, stock, as well as unstacked 2-
D bar, column, area and line graphs.
You cannot add a trendline to 3-D or stacked charts, pie,
radar and similar visuals.
Below, there is an example of a scatter plot with an extended
trendline:
How to add a trendline in
Excel
In Excel 2019, Excel 2016 and Excel 2013, adding a trend line
is a quick 3-step process:
1. Click anywhere in the chart to select it.
2. On the right side of the chart, click the Chart
Elements button (the cross button), and then do one of the
following:
o Check the Trendline box to insert the default
linear trendline:

o Click the arrow next to the Trendline box and


choose one of the suggested types:

o Click the arrow next to Trendline, and then


click More Options. This will open the Format
Trendline pane, where you switch to the Trendline
Options tab to see all the trend line types available in Excel
and choose the one you want. The default Linear trendline
will be pre-selected automatically. Optionally, you can
also display the trendline equation in the chart.

Tip. Another quick way to add trendline to an Excel chart is to


right-click the data series and then click Add Trendline….

How to make a trendline in Excel


2010
To add a trendline in Excel 2010, you follow a different route:
1. On a chart, click the data series for which you want to
draw a trendline.
2. Under Chart Tools, go to the Layout tab
> Analysis group, click Trendline and either:
o Pick one of the predefined options, or
o Click More Trendline Options…, and then choose
the trendline type for your chart.
How to insert multiple
trendlines in the same chart
Microsoft Excel allows adding more than one trendline to a
chart. There are two scenarios that should be handled
differently.

Add a trendline for each data series


To put a trendline on a chart that has two or more data series,
here's what you do:
1. Right-click the data points of interest (blue ones in this
example) and choose Add Trendline… from the context
menu:

2. This will open the Trendline Options tab of the pane,


where you can choose the desired line type:

3. Repeat the above steps for the other data series.


As the result, each data series will have its own trendline of
the matching color:

Alternatively, you can click the Chart Elements button, then


click the arrow next to Trendline and choose the type you
want. Excel will show a list of the data series plotted in your
chart. You pick the needed one and click OK.

Draw different trendline types for the


same data series
To make two or more different trendlines for the same data
series, add the first trendline as usual, and then do one of the
following:

 Right-click the data series, select Add Trendline… in the


context menu, and then choose a different trend line type on
the pane.
 Click the Chart Elements button, click the arrow next
to Trendline and choose the type you want to add.
Either way, Excel will display multiple trendlines in the
chart, Linear and Moving average in our case, for which you
can set different colors:

How to format a trendline in


Excel
To make your graph even more understandable and easily
interpreted, you may want to change the default appearance
of a trendline. For this, right-click it and then click Format
Trendline… . Or simply double-click the trendline to open
the Format Trendline pane.

On the pane, switch to the Fill & Line tab and choose the


color, width and dash type for your trendline. For example,
you can make it a solid line rather than a dashed line:

How to extend trendline in


Excel
To project the data trends into the future or past, this is what
you need to do:
1. Double-click the trendline to open the Format
Trendline pane.
2. On the Trendline Options tab (the last one), type the
desired values in the Forward and/or Backward boxes
under Forecast:
In this example, we choose to extend the trendline for 8
periods beyond the last data point:
Excel trendline equation
Trendline equation is a formula that mathematically
describes the line that best fits the data points. The equations
are different for different trendline types, though in every
equation Excel uses the least squares method to find the
best fit for a line though data points. You can find the
equations for all Excel trendlines types in this tutorial.
When drawing the line of best fit in Excel, you can display its
equation in a chart. Additionally, you can display the R-
squared value.
R-squared value (Coefficient of Determination) indicates how
well the trendline corresponds to the data. The closer the
R2 value to 1, the better the fit.

How to display the trendline


equation on a chart
To show the equation and R-squared value on a chart, do the
following:
1. Double-click the trendline to open its pane.
2. On the pane, switch to the Trendline Options tab and
check these boxes:
o Display Equation on chart
o Display R-squared value on chart
This will put the trendline formula and the R2 value at the top
of your graph, and you are free to drag them wherever you
see fit.
In this example, the R-squared value equals 0.957, which
means that the trendline fits about 95% of data values.

Note. The equation displayed on an Excel chart is correct


only for XY scatter plots. For more information, please
see Why Excel trendline equation is wrong.
Show more digits in the trendline
equation
If the Excel trendline equation delivers inaccurate results
when you supply x values to it manually, most likely it's
because of rounding. By default, the numbers in the trendline
equation are rounded to 2 - 4 decimal places. However, you
can easily make more digits visible. Here's how:
1. Select the trendline formula in the chart.
2. On the Format Trendline Label pane that appears, go to
the Label Options tab.
3. In the Category drop-down list, select Number.
4. In the Decimal places box, type the number of decimal
places you want to show (up to 30) and press Enter to
update the equation in the chart.
How to find the slope of a
trendline in Excel
To get the slope of the linear trendline, Microsoft Excel
provides a special function of the same name:
SLOPE(known_y's, known_x's)

Where:

 Known_y's is a range of the dependent data points


plotted on the y-axis.
 Known_x's is a range of the independent data points
plotted on the x-axis.
With the x values in B2:B13 and the y values in C2:C13, the
formula goes as follows:
=SLOPE(C2:C13, B2:B13)

The slope can also be calculated by using the LINEST


function in a regular formula:
=LINEST(C2:C13,B2:B13)

If entered as an array formula by pressing Ctrl + Shift +


Enter, it would return the slope of the trendline and y-intercept
into two adjacent cells in the same row. For more information,
please see How to use the LINEST function in Excel.
As you can see in the following screenshot, the slope value
returned by the formulas exactly matches the slope coefficient
in the linear trendline equation displayed in our graph:

The coefficients of other trendline equation types


(Exponential, Polynomial, Logarithmic, etc.) can also be
calculated, but you'd need to use more complex formulas
explained in Excel trendline equations.

How to delete a trendline in


Excel
To remove a trendline from your chart, right-click the line, and
then click Delete:

Or click the Chart Elements button and unselect


the Trendline box:
Either way, Excel will immediately remove the trendline from a
chart.

Trendline in Excel
A trendline, also referred to as a line of best fit, is a straight
or curved line in a chart that shows the general pattern or
overall direction of the data.
This analytical tool is most often used to show data
movements over a period of time or correlation between two
variables.

Excel trendline types


When adding a trendline in Excel, you have 6 different options
to choose from. Additionally, Microsoft Excel allows displaying
a trendline equation and R-squared value in a chart:

 Trendline equation is a formula that finds a line that


best fits the data points.
 R-squared value measures the trendline reliability - the
nearer R2 is to 1, the better the trendline fits the data.

Below, you will find a brief description of each trendline type


with chart examples.
Linear trendline
The linear trend line is best to be used with linear data sets
when the data points in a chart resemble a straight line.
Typically, a linear trendline describes a continuous rise or fall
over time.
For example, the following linear trendline shows a steady
increase in sales over 6 months. And the R2 value of 0.9855
indicates a pretty good fit of the estimated trendline values to
the actual data.

Exponential trendline
The exponential trendline is a curved line that illustrates a rise
or fall in data values at an increasing rate, therefore the line is
usually more curved at one side. This trendline type is often
used in sciences, for example to visualize a human population
growth or decline in wildlife populations.
Please note that an exponential trendline cannot be created
for data that contains zeros or negative values.
A good example of an exponential curve is the decay in the
entire wild tiger population on the earth.
Logarithmic trendline
The logarithmic best-fit line is generally used to plot data that
quickly increases or decreases and then levels off. It can
include both positive and negative values.
An example of a logarithmic trendline may be an inflation rate,
which first is getting higher but after a while stabilizes.

Polynomial trendline
The polynomial curvilinear trendline works well for large data
sets with oscillating values that have more than one rise and
fall.
Generally, a polynomial is classified by the degree of the
largest exponent. The degree of the polynomial trendline can
also be determined by the number of bends on a graph.
Typically, a quadratic polynomial trendline has one bend (hill
or valley), a cubic polynomial has 1 or 2 bends, and a quartic
polynomial has up to 3 bends.
When adding a polynomial trendline in an Excel chart, you
specify the degree by typing the corresponding number in
the Order box on the Format Trendline pane, which is 2 by
default:

For example, the quadratic polynomial trend is evident on the


following graph that shows the relationship between the profit
and the number of years the product has been on the market:
rise in the beginning, peak in the middle and fall near the end.

Power trendline
The power trend line is very similar to the exponential curve,
only it has a more symmetrical arc. It is commonly used to
plot measurements that increase at a certain rate.
A power trendline cannot be added to an Excel chart that
contains zero or negative values.
As an example, let's draw a power trendline to visualize the
chemical reaction rate. Note the R-squared value of 0.9918,
which means that our trendline fits the data almost perfectly.

Moving average trendline


When the data points in your chart have a lot of ups and
downs, a moving average trendline can smooth the extreme
fluctuations in data values to show a pattern more clearly. For
this, Excel calculates the moving average of the number of
periods that you specify (2 by default) and puts those average
values as points in the line. The higher the Period value, the
smoother the line.
A good practical example is using the moving average
trendline to reveal fluctuations in a stock price that otherwise
would be difficult to observe.
For more information, please see: How to add a moving
average trendline to an Excel chart.

Excel trendline equations and


formulas
This section describes the equations that Excel uses for
different trendline types. You do not have to build these
formulas manually, simply tell Excel to display the trendline
equation in a chart.
Also, we will discuss the formula to find the slope of a
trendline and other coefficients. The formulas assume that
you have 2 sets of variables: independent variable
x and dependent variable y. In your worksheets, you can
use these formulas to get the predicted y values for any given
values of x.
For consistency, we will be using the same data set with
slightly varying values for all the examples. However, please
keep in mind that it's only for demonstration purposes. In your
real worksheets, you should choose the trendline
type corresponding to your data type.
Important note! The trendline formulas should only be used
with XY scatter charts because only this chart plots
both x and y axes as numeric values. For more information,
please see Why Excel trendline equation may be wrong.
Linear trendline equation and
formulas
The linear trendline equation uses the least squares methods
to seek the slope and intercept coefficients such that:
y = bx + a

Where:

 b is the slope of a trendline.


 a is the y-intercept, which is the expected mean value
of y when all x variables are equal to 0. On a chart, it's the
point where the trendline crosses the y axis.
For linear regression, Microsoft Excel provides special
functions to get the slope and intercept coefficients.
Slope of trendline
b: =SLOPE(y,x)
Y-intercept
a: =INTERCEPT(y,x)
Assuming the x range is B2:B13 and the y range is C2:C13,
the real-life formulas go as follows:
=SLOPE(C2:C13, B2:B13)

=INTERCEPT(C2:C13,B2:B13)

The same results can be achieved by using


the LINEST function as an array formula. For this, select 2
adjacent cells in the same row, enter the formula and
press Ctrl + Shift + Enter to complete it:
=LINEST(C2:C13,B2:B13)

As shown in the screenshot below, the slope and intercept


coefficients returned by the formulas are perfectly in line with
the coefficients in the linear trendline equation displayed in
the chart, only the latter are rounded to 4 decimal places:

Exponential trendline equation and


formulas
For the exponential trendline, Excel uses the following
equation:
y = aebx

Where a and b are calculated coefficients and e is the


mathematical constant e (the base of the natural logarithm).
The coefficients can be calculated by using these generic
formulas:
a: =EXP(INDEX(LINEST(LN(y), x), 1, 2))

b: =INDEX(LINEST(LN(y), x), 1)

For our sample data set, the formulas take the following
shape:
a: =EXP(INDEX(LINEST(LN(C2:C13), B2:B13), 1, 2))

b: =INDEX(LINEST(LN(C2:C13), B2:B13), 1)
Logarithmic trendline equation and
formulas
Here's the logarithmic trendline equation in Excel:
y = a*ln(x)+b

Where a and b are constants and ln is the natural logarithm


function.
To get the constants, use these generic formulas, which only
differ in the last argument:
a: =INDEX(LINEST(y, LN(x)), 1)

b: =INDEX(LINEST(y, LN(x)), 1, 2)

For our sample data set, we use these ones:


a: =INDEX(LINEST(C2:C13, LN(B2:B13)), 1)

b: =INDEX(LINEST(C2:C13, LN(B2:B13)), 1, 2)

Polynomial trendline equation and


formulas
To work out the polynomial trendline, Excel uses this
equation:
y = b6x6 + … + b2x2  + b1x + a
Where b1…b6 and a are constants.
Depending on the degree of your polynomial trendline, use
one of the following sets of formulas to get the constants.

Quadratic (2nd order) polynomial trendline


Equation: y = b2x2+ b1x + a
b2: =INDEX(LINEST(y, x^{1,2}), 1)

b1: =INDEX(LINEST(y, x^{1,2}), 1, 2)

a: =INDEX(LINEST(y, x^{1,2}), 1, 3)

Cubic (3rd order) polynomial trendline


Equation: y = b3x3 + b2x2+ b1x + a
b3: =INDEX(LINEST(y, x^{1,2,3}), 1)

b2: =INDEX(LINEST(y, x^{1,2,3}), 1, 2)

b1: =INDEX(LINEST(y, x^{1,2,3}), 1, 3)

a: =INDEX(LINEST(y, x^{1,2,3}), 1, 4)

The formulas for higher degree polynomial trendlines can be


built by using the same pattern.
For our data set, the 2nd order polynomial trendline suites
better, so we are using these formulas:
b2: =INDEX(LINEST(C2:C13, B2:B13^{1,2}), 1)

b1:  =INDEX(LINEST(C2:C13, B2:B13^{1,2}), 1, 2)
a:  =INDEX(LINEST(C2:C13, B2:B13^{1,2}), 1, 3)

Power trendline equation and


formulas
A power trendline in Excel is drawn based on this simple
equation:
y = axb

Where a and b are constants, which can be calculated with


these formulas:
a: =EXP(INDEX(LINEST(LN(y), LN(x),,), 1, 2))

b: =INDEX(LINEST(LN(y), LN(x),,), 1)

In our case, the following formulas work a treat:


a: =EXP(INDEX(LINEST(LN(C2:C13), LN(B2:B13),,), 1, 2))

b: =INDEX(LINEST(LN(C2:C13), LN(B2:B13),,), 1)
Excel trendline equation is
wrong - reasons and fixes
If you think that Excel has drawn a trendline incorrectly or the
trendline formula displayed in your chart is wrong, the
following two points may shed some light on the situation.

Excel trendline equation is correct


only in scatter charts
Excel trendline formulas should only be used with XY (scatter)
graphs because only in this chart type both the y-axis and x-
axis are plotted as numeric values.
In line charts, column and bar graphs, numeric values are
plotted only on the y-axis. The x-axis is represented by a
linear series (1, 2, 3,…) regardless of whether the axis labels
are numbers or text. When you make a trendline in these
charts, Excel uses those assumed x-values in the trendline
formula.

Numbers are rounded in Excel


trendline equation
To occupy less space in the chart, Excel displays very few
significant digits in a trendline equation. Nice in terms of
design, it significantly reduces the formula's accuracy when
you manually supply x values in the equation.
An easy fix is to show more decimal places in the equation.
Alternatively, you can calculate the coefficients by using a
formula corresponding to your trendline type, and format the
formula cells so that they show a sufficient number of decimal
places. For this, simply click the Increase Decimal button on
the Home tab in the Number group.

You might also like