Peltier Technical Services, Inc.
 

Excel Chart Add-Ins | Training | Charts and Tutorials | Peltier Tech Blog


Peltier Tech Charts for Excel 3.0

 

Charting Dynamic Normalized Ranges.

Often it is desirable to plot multiple series so that their values are normalized to an initial value of, say, 100. This is particularly useful when comparing performance of stock prices on a relative basis. This article shows how to use dynamic ranges and dynamic charts to display normalized values.

More examples of dynamic charts can be found by following links on Dynamic and Interactive Charts.

The Data

The sample data consists of a month's worth of dates in column A plus corresponding values in columns B and C. Row 1 contains column headers, so the actual data starts in row 2.

To allow for dynamic charting, cell E2 contains a parameter for the starting point index of the dynamic data, and cell F2 contains another parameter for the number of points in the dynamic data.

These various ranges will be assigned names below.

  A B C
1 Date Value1 Value2
2 1-Dec-06 52.50 24.40
3 2-Dec-06 50.61 24.12
4 3-Dec-06 52.55 21.96
5 4-Dec-06 48.80 23.22
6 5-Dec-06 47.64 21.13
7 6-Dec-06 44.29 21.97
8 7-Dec-06 43.80 22.50
9 8-Dec-06 43.97 21.36
10 9-Dec-06 46.88 22.88
11 10-Dec-06 42.69 24.22
12 11-Dec-06 41.07 22.35
13 12-Dec-06 38.26 21.79
14 13-Dec-06 37.09 23.70
15 14-Dec-06 40.11 22.71
16 15-Dec-06 40.85 23.53
17 16-Dec-06 39.92 24.33
18 17-Dec-06 41.97 22.62
19 18-Dec-06 37.90 22.56
20 19-Dec-06 36.84 22.47
21 20-Dec-06 34.56 22.71
22 21-Dec-06 37.11 23.67
23 22-Dec-06 35.44 25.45
24 23-Dec-06 36.63 24.99
25 24-Dec-06 33.70 25.51
26 25-Dec-06 31.95 23.28
27 26-Dec-06 31.52 22.00
28 27-Dec-06 31.35 21.50
29 28-Dec-06 30.09 21.77
30 29-Dec-06 28.94 23.21
31 30-Dec-06 26.83 23.33
32 31-Dec-06 27.48 24.26
  E F
1 Start Length
2 5 12

Defining The Names

A "Name" is what Excel calls a variable. A Name has two parts, a name and a formula that defines what the Name refers to. Sometimes a Name is called a "Named Range", but a more accurate description would be "Named Formula".

If I wanted a Name to refer to a constant, I would give it a name like Two and a refers to formula of =2. If I wanted another name to refer to a range, I might name it MyRange and assign it a formula of =Sheet1!$A$1:$C$10. Names can be more complicated than this, incorporating Excel's worksheet formulas to produce almost any result. For example, the names defined below include both OFFSET and INDEX functions.

It helps to give consideration to the names of your Names. The name of a Name can use letters and numerals and a few punctuation marks, but it's safer to limit these to the underscore character and the period (and I don't even use periods); the name must start with a letter or an underscore. Since the Names in this example all refer to worksheet ranges, I use a prefix of "rng". Often, to indicate ranges used for chart data, I use a prefix of "cht" for the prefix. Use a convention that makes sense and will help you remember two months later what the Names refer to. For example, in this example, I use "rngValue1" to refer to the entire set of values for series 1, "rngSelectedValue1" to refer to the selected subset of the series 1 values, and "rngSelectedValue1Norm" to refer to the normalized selected values of series 1.

The table below describes the Names used in this example:

Name Refers To
rngDates =OFFSET(DataSheet!$A$1,1,0,COUNT(DataSheet!$A:$A),1)
rngValue1 =OFFSET(rngDates,,1)
rngValue2 =OFFSET(rngDates,,2)
rngStart =DataSheet!$E$2
rngLength =DataSheet!$F$2
rngSelectedDates =INDEX(rngDates,rngStart):INDEX(rngDates,rngStart+rngLength-1)
rngSelectedValue1 =OFFSET(rngSelectedDates,,1)
rngSelectedValue2 =OFFSET(rngSelectedDates,,2)
rngSelectedValue1Norm =rngSelectedValue1/INDEX(rngSelectedValue1,1)*100
rngSelectedValue2Norm =rngSelectedValue2/INDEX(rngSelectedValue2,1)*100

Note for Excel 2007 users: This technique will fail if your Names begin with the word "Chart". Use names like ChtValues instead of ChartValues.

To define a Name which is based on a static range, select the range, and type a name in the Name Box (the small box above the top left cell, to the left of the formula bar), and press Enter. To define any Name, go to the Insert menu, select Name, then select Define (or use the shortcut Ctrl+F3). The Define Name dialog has a Name box for entering a name for a Name, a Names in Workbook listbox showing names that have already been defined, and a Refers To box for the refers-to formula. Simply enter a name and a formula, and click Add.

The scope of a Name, that is, the amount of the environment that it is relevant within, can be changed by how the Name is named. To define a Name that references a worksheet only, enter its name with the worksheet name as a prefix: DataSheet!rngDates. This limits the scope of the Name to the worksheet. If the name does not include a worksheet name, the scope of the Name is the whole workbook. The Names in this example have been defined for the entire workbook.

The OFFSET formula consists of five parameters: a reference range, a row offset, a column offset, an optional row count, and an optional column count. For example,

    =OFFSET(DataSheet!$A$1,1,0,COUNT(DataSheet!$A:$A),1)

means the defined Name starts at DataSheet!$A$1, but offset down 1 row and right 0 columns, and is COUNT(DataSheet!$A:$A) rows high (the number of numerical values counted in column A, and remember that a date is a numerical value) and 1 columns wide.

    =OFFSET(rngDates,,1)

means the defined Name consists of the range defined by rngDates, but offset down 0 rows and right 1 columns. The absence of row and column count parameters means the new Name is the same size as the reference range rngDates.

    =rngSelectedValue1/INDEX(rngSelectedValue1,1)*100

means the new Name consists of the values in the Name rngSelectedValue1, divided by INDEX(rngSelectedValue1,1), that is, the first value in rngSelectedValue1), and multiplied by 100.

I find it helpful to display the values of my Names in a worksheet to make sure I've properly defined them. The table below shows how values for all of my date and value Names. To populate a worksheet range with a Name, you select the worksheet range, then array-enter a formula referring to the Name. This means you type a formula like =rngDates, then hold Ctrl and Shift while pressing Enter. If done correctly, Excel places curly braces around the formula: {=rngDates}. I use a larger range than my Names require, for example, H2:H35 for rngDates; any excess cells beyond the end of a Name are filled with #N/A errors.

  H I J K L M N O
1 rngDates rngValue1 rngValue2 rngSelectedDates rngSelectedValue1 rngSelectedValue2 rngSelectedValue1Norm rngSelectedValue2Norm
2 1-Dec-06 52.50 24.40 5-Dec-06 47.64 21.13 100 100
3 2-Dec-06 50.61 24.12 6-Dec-06 44.29 21.97 92.96809404 103.9753904
4 3-Dec-06 52.55 21.96 7-Dec-06 43.80 22.50 91.9395466 106.4836725
5 4-Dec-06 48.80 23.22 8-Dec-06 43.97 21.36 92.29638959 101.0884998
6 5-Dec-06 47.64 21.13 9-Dec-06 46.88 22.88 98.40470193 108.2820634
7 6-Dec-06 44.29 21.97 10-Dec-06 42.69 24.22 89.60957179 114.6237577
8 7-Dec-06 43.80 22.50 11-Dec-06 41.07 22.35 86.20906801 105.7737814
9 8-Dec-06 43.97 21.36 12-Dec-06 38.26 21.79 80.31066331 103.1235211
10 9-Dec-06 46.88 22.88 13-Dec-06 37.09 23.70 77.85474391 112.1628017
11 10-Dec-06 42.69 24.22 14-Dec-06 40.11 22.71 84.19395466 107.4775201
12 11-Dec-06 41.07 22.35 15-Dec-06 40.85 23.53 85.7472712 111.3582584
13 12-Dec-06 38.26 21.79 16-Dec-06 39.92 24.33 83.79513014 115.1443445
14 13-Dec-06 37.09 23.70 #N/A #N/A #N/A #N/A #N/A
15 14-Dec-06 40.11 22.71 #N/A #N/A #N/A #N/A #N/A
16 15-Dec-06 40.85 23.53 #N/A #N/A #N/A #N/A #N/A
17 16-Dec-06 39.92 24.33 #N/A #N/A #N/A #N/A #N/A
18 17-Dec-06 41.97 22.62 #N/A #N/A #N/A #N/A #N/A
19 18-Dec-06 37.90 22.56 #N/A #N/A #N/A #N/A #N/A
20 19-Dec-06 36.84 22.47 #N/A #N/A #N/A #N/A #N/A
21 20-Dec-06 34.56 22.71 #N/A #N/A #N/A #N/A #N/A
22 21-Dec-06 37.11 23.67 #N/A #N/A #N/A #N/A #N/A
23 22-Dec-06 35.44 25.45 #N/A #N/A #N/A #N/A #N/A
24 23-Dec-06 36.63 24.99 #N/A #N/A #N/A #N/A #N/A
25 24-Dec-06 33.70 25.51 #N/A #N/A #N/A #N/A #N/A
26 25-Dec-06 31.95 23.28 #N/A #N/A #N/A #N/A #N/A
27 26-Dec-06 31.52 22.00 #N/A #N/A #N/A #N/A #N/A
28 27-Dec-06 31.35 21.50 #N/A #N/A #N/A #N/A #N/A
29 28-Dec-06 30.09 21.77 #N/A #N/A #N/A #N/A #N/A
30 29-Dec-06 28.94 23.21 #N/A #N/A #N/A #N/A #N/A
31 30-Dec-06 26.83 23.33 #N/A #N/A #N/A #N/A #N/A
32 31-Dec-06 27.48 24.26 #N/A #N/A #N/A #N/A #N/A
33 #N/A #N/A #N/A #N/A #N/A #N/A #N/A #N/A
34 #N/A #N/A #N/A #N/A #N/A #N/A #N/A #N/A
35 #N/A #N/A #N/A #N/A #N/A #N/A #N/A #N/A
36 #N/A #N/A #N/A #N/A #N/A #N/A #N/A #N/A
37 #N/A #N/A #N/A #N/A #N/A #N/A #N/A #N/A
38 #N/A #N/A #N/A #N/A #N/A #N/A #N/A #N/A
39 #N/A #N/A #N/A #N/A #N/A #N/A #N/A #N/A
Creating The Dynamic Charts
1. A static chart containing all of the data

The chart is initially created by selecting the range A1:C32 and creating a line chart.

The series formulas for the two plotted series are shown below. Note that they include fixed links to static worksheet ranges.

    =SERIES(DataSheet!$B$1,DataSheet!$A$2:$A$32,DataSheet!$B$2:$B$32,1)
    =SERIES(DataSheet!$C$1,DataSheet!$A$2:$A$32,DataSheet!$C$2:$C$32,2)
2. A dynamic chart containing all of the data

To convert each chart series to a dynamic series, change the references in the formula from fixed worksheet ranges (i.e., $A$2:$A$32 or $B$2:$B$32) to defined Names (rngDates or rngValue1). For me, the easiest way to do this is to select the series, and edit the series formula directly in the formula bar. You can also select Source Data from the Chart menu, click on the Series tab, select a series, and edit the references in the input boxes in this dialog.

    =SERIES(DataSheet!$B$1,DataSheet!rngDates,DataSheet!rngValue1,1)
    =SERIES(DataSheet!$C$1,DataSheet!rngDates,DataSheet!rngValue2,2)

Since the Names were defined for the entire workbook, Excel changes the worksheet name in the range reference (DataSheet) to the workbook name (Normalized.xls):

    =SERIES(DataSheet!$B$1,Normalized.xls!rngDates,Normalized.xls!rngValue1,1)
    =SERIES(DataSheet!$C$1,Normalized.xls!rngDates,Normalized.xls!rngValue2,2)

This chart appears the same as the static chart above, but it is dynamic. If rows were added or removed from the data range, the chart would automatically update to show all data in the range.

3. A dynamic chart containing a selection of the data

To change the dynamic chart so it includes only the selected data defined by the rngStart and rngLength parameters, change the Names in the series formulas (rngDates, rngValue1) to the Names that reference the selected ranges (rngSelectedDates, rngSelectedValue1)

    =SERIES(DataSheet!$B$1,Normalized.xls!rngSelectedDates,Normalized.xls!rngSelectedValue1,1)
    =SERIES(DataSheet!$C$1,Normalized.xls!rngSelectedDates,Normalized.xls!rngSelectedValue2,2)

4. A dynamic chart containing a selection of the data, normalized to 100 at the starting point

Finally, to show the normalized values in the chart, change from the selected Names (rngSelectedValue1) to the normalized Names (rngSelectedValue1Norm) in the series formula:

    =SERIES(DataSheet!$B$1,Normalized.xls!rngSelectedDates,Normalized.xls!rngSelectedValue1Norm,1)
    =SERIES(DataSheet!$C$1,Normalized.xls!rngSelectedDates,Normalized.xls!rngSelectedValue2Norm,2)

The chart above shows the data for the original starting value of 5 and length value of 12. When these values are changed to 13 and 19, the chart automatically adjusts.

Here are more Dynamic Chart resources on this web site:

For a partial list of internet links to dynamic charting, click here.

Alse see Dynamic Charts on the PTS Blog.

 

Peltier Tech Charts for Excel 3.0


Peltier Technical Services, Inc.

Excel Chart Add-Ins | Training | Charts and Tutorials | PTS Blog

Peltier Technical Services, Inc., Copyright © 2017. All rights reserved.
You may link to this article or portions of it on your site, but copying is prohibited without permission of Peltier Technical Services.

Microsoft Most Valuable Professional

Microsoft Most Valuable Professional

My MVP Profile