how to add an average line to the graph in excel 2007 or 2010

5

In OpenOffice I'm getting trend-line and average-line properties by RightClick. But in Excel 2007 I see only trend-line. Same with Excel 2010. How do you make an average-line in Excel?

stim

Posted 2010-05-26T19:23:19.400

Reputation: 1 294

4Make one yourself from an extra column in your spreadsheet;-) – trolle3000 – 2010-05-26T19:29:46.987

I can... but I need this occasionally for different columns. Maybe there is any "two-click" shortcuts... – stim – 2010-05-26T20:59:04.923

1There is no existing short-cut. You will have to write your own macro. – systemovich – 2010-07-13T13:47:09.413

Answers

4

BTW, I've got desired macros:

Sub averageline()

' Adds line of average value for the selected series

Dim s As Series, v, m As Double, v1, i As Long
On Error GoTo err_selection
Set s = Selection
On Error GoTo 0
v = s.Values
m = WorksheetFunction.Average(v)
v1 = v
For i = LBound(v) To UBound(v)
    v1(i) = m
Next
With ActiveChart.SeriesCollection.NewSeries
    .XValues = s.XValues
    .Values = v1
    .Name = "Average " & s.Name
    .AxisGroup = s.AxisGroup
    .MarkerStyle = xlNone
    .Border.Color = s.Border.Color
End With

Exit Sub

err_selection:
    MsgBox "Selection don't represent series on the chart", vbCritical
    Exit Sub
End Sub

After adding it, you'll be able to simply select any row on your graph, then alt+f8, select macros and enter.

stim

Posted 2010-05-26T19:23:19.400

Reputation: 1 294

3

I only have Excel 2003, but I think it should be the same.

I created a line chart then right-clicked on one of the data lines. The first item on the right-click menu was "Format Data Series..." On that right-click menu is "Add Trendline"

This will give you a bunch of options for the type of trendline. From the Options tab, you can have it forecast forward and backward as well.

chrismar035

Posted 2010-05-26T19:23:19.400

Reputation: 203

1I need average - exact value, not the upward or downward trend. I can't see value on trend line. – stim – 2010-05-26T21:04:01.480

What do you mean by "you can't see value on trend line"? If you want to see the equation of the trendline, that's an option when you customize the trendline. If you mean you can't see the use of a trendline, it's so that you can see the best-fit line for the dataset. – nhinkle – 2010-07-21T05:51:28.660

1No. Trendline just tell us the trend. Average line is a simple horizontal line with average value. – stim – 2012-03-21T18:16:58.293

1

Assuming an already existing XY Scatter chart:

  1. Add a column to your spreadsheet where the chart data resides. In this column, for every row enter the average. You will have calculated this average beforehand using AVERAGE() or SUM(data range)/(number of rows). You should now have a column that has the same value for every cell. You can title this Average, or something relevant to your needs.

  2. In your chart, add another data series. This new series will be of the same type as your existing data line. Everything about this new series will be the same as the existing data series, except you will now use this new column as the range instead of the range you used for the data series (you'll probably also want to use a different title). Most likely you are changing the range used for the Series Y values (assuming a horizontal line showing the average). The point I'm trying to convey here is that the only difference between your data line and your average line will be that the average line uses the average column you just created instead of values used to create the original chart. This will draw a straight horizontal (no slope) average line.

  3. Format the line to your tastes.

shufler

Posted 2010-05-26T19:23:19.400

Reputation: 1 716