|
|
|||
| | OFFSET() function | Graph tips | Grouping data for charts | | |||
Line graphs or charts are an appropriate format for showing values over a period of time. Unfortunately, if there is one data series which has fewer categories than another and contains values of zero, a line plotted by Excel will correspondingly fall to zero on the Y axis. This looks misleading on a chart.
| - | A | B | C | D | E | F | G |
| 1 | Expenditure | 4 | Month No | ||||
| 2 | |||||||
| 3 | Apr | May | Jun | Jul | Aug | Sep | |
| 4 | This Yr | 12 | 15 | 14 | 16 | 0 | 0 |
| 5 | Last Yr | 11 | 10 | 13 | 13 | 14 | 12 |
In the example (right) which shows a comparison of expenditure last year and this year, the current year data series has fewer values (i.e. April to July only). If the remaining month values in the table are left blank your graph will be unaffected. However if all of the cells use lookup formulae to read values from a list of data, the table will contain zero values for the last two months.
It is possible to instruct an Excel chart to automatically ignore the unwanted latter part of the series. The OFFSET function can be applied to resize the range of the graph for a particular series of values.
![]() |
|
![]() |
This methodology can also be applied so that the whole graph (including X axis categories) grows automatically to include a dynamically sized table. As more columns of data are added to the table, the graph will extend to include them. This can be done without the need for a cell containing a month value. In the OFFSET function which is used to define the Name, instead of using 'Main!$E$1', the function 'COUNTA($B$3:$M$3)' would count and capture all of the X axis labels (see 'MonthNames' in the picture above). A separate defined Name would be required for each of the components on the Chart - i.e. a name for the X data labels, another name for the current year row values and another name for the old year row values. Using COUNT() or COUNTA() functions will not avoid the zero values which was the purpose of the previous example.
* Note that filenames containing spaces must be enclosed in apostrophes (i.e. 'Monthly Graph.xls'!ExpendThis)
| Get this information as a document accompanied by Excel worksheets |
Click here for details about obtaining this file |
| file:xlgraphoffset | © meadinkent.co.uk 2006 | Page last updated Aug06 |