Trendlines in Excel


This post is on how to manually calculate trend lines in Excel. I will show examples of the trended data graphed against the original data. Excel graphs can automatically add trend lines based on all of these trend methods. However, this post will show you how to manually calculate all of them should you want to forecast a trend line past the known data set to calculate predicted values for x & y.

Please note that this post will not show you how to figure out which trend line is best for forecasting future data, however we will discuss figuring out which trend line best correlates to current data.

Typically, you will have x or y values and need to calculate what the corresponding x or y values are. Rarely will you have to forecast both x & y. This post will assume that you know your x values and are trying to forecast your y values.

The most simple of trend lines is to “fit” a linear line to your data. The equation for a linear line is y = m*x+b.

The coefficients for this equation are m & b where m is the slope of the line and b is where the line intercepts the y-axis. To calculate these coefficients, Excel has built-in formulas, SLOPE & INTERCEPT. For the rest of the examples below, there are no built-in formulas.

For each type of trend line, I will present the coefficients, the equation to calculate each coefficient and then the calculated value based on the following data set:

X Y
1 1
2 1
3 5.5
4 9
5 10
6 14
7 13
8 14
9 14
10 17

Getting back to our Linear equation, y = m*x+b, the equations for the coefficients m & b are:


m = SLOPE(y,x)
b = INTERCEPT(y,x)

where y are your known y’s & x are your known x’s.

To forecast y values for your known x’s you then simply plug these coefficient values into the equation for a line and solve for y.

Logarithmic Trend Line

Logarithmic Equation: y=(c*LN(x))+b

where:

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

where y are your known y’s & x are your known x’s. In addition, these formulas are entered using CTRL+SHIFT+ENTER to enter them as an array formula – otherwise the function will not work correctly – it expects an array of data.

Exponential Trend Line

Exponential Equation: y=c*e^(b*x)

where:

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

Where again, y are your known y’s & x are your known x’s and these formulas are entered using CTRL+SHIFT+ENTER to enter them as an array formula.

Power Trend Line

Power Equation: y=c*x^b

where:

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

Again, y are your known y’s & x are your known x’s and these formulas are entered using CTRL+SHIFT+ENTER to enter them as an array formula.

2nd Order Polynomial Trend Line

Power Equation: y=(a*x^2)+(b*x)+c

where:

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

Again, y are your known y’s & x are your known x’s and these formulas are entered using CTRL+SHIFT+ENTER to enter them as an array formula.

3rd Order Polynomial Trend Line

Power Equation: y=(a*x^3)+(b*x^2)+(c*x)+d

where:

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

Again, y are your known y’s & x are your known x’s and these formulas are entered using CTRL+SHIFT+ENTER to enter them as an array formula.

Seeing a pattern? In order to find an n’th order polynomial, you simply use the coefficient equation n = INDEX(LINEST(y,x^{1,2,3…n}),1,n)

So how do these look when you calculate the forecasted y’s & graph them all together?

Trendline Examples
(Click on picture to enlarge)

So how do you know which type of trend line is “better”? Better can be subjective however one way to decide is to see how close your trended y values fit the y values of your original line. You can use the CORREL function in excel to find out how correlated your trended y values are to your original y values. In this instance, the 3rd Order Polynomial Trendline has the largest correlation (1 = perfect correlation, 0 = no correlation) indicating that it’s the best “fit” to our original data. Unfortunately, this only works for the known y’s. As you can see from the picture above – the polynomial equations have started to curve over to the right and flatten out, whereas the original data points seem to indicate an upward trend. How to choose a forecasting method will have to wait for another post.

Questions? Did I make a mistake? Let me know in the comments below!

Social Media 101: Content & Consistency


I have been running the social media strategy team for my company for a little over two years now. During that time, we have:

  • Doubled the amount of traffic to our website
  • Set up a consistent presence on four social media channels
  • Played with another two social media channels
  • Attempted to optimize our website for SEO
  • Set up processes for:
    • Content generation
    • Content publication
    • Channel strategy
  • Implemented a response plan
  • Promoted social media for internal communications – including launching two new tools, Yammer and Lync
  • Created & delivered Social Media training to the entire firm
  • Helped a non-profit organization develop their Social Media strategy

Given all of that experience – I have been thinking a lot about Social Media and here is what I conclude works: Content and Consistency.

During my journey in Social Media, I have read a number of books and countless articles on how to succeed at Social Media and for all the volumes written on the subject, I don’t think it is any more complicated than the two C’s.

There is obviously a lot of thought that needs to go into your content and into your scheduling for consistency but your goal does not need to be any more complicated than trying to consistently publish good content.

Myriads of articles have been written on how to become the next big internet sensation/meme/viral phenomenon/etc. and while it would be amazing to catch that next big wave, in reality your odds are astronomical. It’s like trying to win the lottery – you keep buying lottery tickets but chances are, you’re not going to win. Instead of trying to catch that wave – great accomplishments can be made, simply by trudging along towards the two C’s.

As you may have guessed at this point, there are no secrets to reaching the two C’s – instead, plan and work towards improving your content and set up a publishing schedule to keep you consistent. In addition, most Social Media tools will allow you to schedule your content so you don’t have to put off writing up your awesome content, you just delay releasing it to your adoring subscribers.

Have questions? Disagree? Let me know in the comments below.

Thanks!