Please Note: This article is written for users of the following Microsoft Excel versions: 97, 2000, 2002, and 2003. If you are using a later version (Excel 2007 or later), this tip may not work for you. For a version of this tip written specifically for later versions of Excel, click here: Calculating Statistical Values on Different-Sized Subsets of Data.

Calculating Statistical Values on Different-Sized Subsets of Data

Written by Allen Wyatt (last updated January 28, 2023)
This tip applies to Excel 97, 2000, 2002, and 2003


Chris has a huge amount of data in a worksheet and he wants to analyze the data based on different groupings within it. For instance, he has data in cells A2:B36001, where row 1 contains the column headings Time and Signal. He wants to divide the data into groups consisting of some arbitrary number of sequential values, and then extract, for each group, a mean value for the Time, a mean value for the Signal, and a standard deviation for the Signal.

The easiest way to handle this type of requirement is to add a column that is used to indicate a group number for each row. Follow these steps:

  1. Put the heading Group into cell C1.
  2. In cell E1 enter the number of values that should be in each group. For instance, if you want each group to contain 10 sequential values, enter the number 10 in cell E1.
  3. In cell C2 enter this formula: =INT((ROW()-ROW($C$2))/$E$1)+1
  4. Copy the formula in cell C2 to the range C3:C36001. Column C now contains a "group number" for each row, based on the value in cell E1. If E1 is 10, you end up with 3600 groups, 1 through 3600. If E1 is 100, you end up with 360 groups, 1 through 360.

With the group numbers set up, you are ready to do the analysis. There are a couple of ways you can do this. One way is to use the subtotaling capabilities of Excel. Select one of the cells in the data area and follow these steps:

  1. Choose Subtotals from the Data menu. Excel displays the Subtotals dialog box.
  2. Change the At Every Change In drop-down list to Group.
  3. Change the Use Function drop-down list to indicate the type of statistic you want to calculate for each group.
  4. Change the Add Subtotal To area so that only Time or Signal are selected, as appropriate.
  5. Click OK.

Excel groups and subtotals the data, as directed. You can hide the detail (and only show the subtotals) by clicking on the small 2 (with the box around it) in the outline area at the left of the worksheet. If you later want to change what is calculated, or if you need to change the number of items in each group, just remove the subtotals (Data | Subtotals | Remove All) and repeat the above steps.

Another way to derive the statistics from your data is to use a PivotTable. Make sure that there are no subtotals in the data and select a cell within the data. Then follow these steps:

  1. Choose PivotTable and PivotChart Report from the Data menu. Excel starts the PivotTable and PivotChart Wizard.
  2. Click Next. (The default selections in step 1 are OK.) Step 2 of the PivotTable and PivotChart Wizard is displayed.
  3. The entire range of your data (A1:C36001) should be selected. Click Next. Step 3 of the PivotTable and PivotChart Wizard is displayed.
  4. Make sure New Worksheet is selected, then click Finish. Excel creates a blank PivotTable and displays a field list.
  5. Drag the Group field to the Row area.
  6. Drag the Time field to the Data area.
  7. Drag the Signal field to the Data area.
  8. Drag the Signal field, once again, to the Data area. The PivotTable should now show "Count of Time," "Sum of Signal," and "Sum of Signal2" for each group.
  9. In the Data area, right-click one of the "Count of Time" labels. Excel displays a Context menu.
  10. Choose Field Settings from the Context menu. Excel displays the PivotTable Field dialog box.
  11. In the Summarize list, choose Average.
  12. Click OK. All the "Count of Time" labels change to "Average of Time."
  13. In the Data area, right-click one of the "Sum of Signal" labels. Excel displays a Context menu.
  14. Choose Field Settings from the Context menu. Excel again displays the PivotTable Field dialog box.
  15. In the Summarize list, choose Average.
  16. Click OK. All the "Sum of Signal" labels change to "Average of Signal."
  17. In the Data area, right-click one of the "Sum of Signal2" labels. Excel displays a Context menu.
  18. Choose Field Settings from the Context menu. Excel again displays the PivotTable Field dialog box.
  19. In the Summarize list, choose StdDev.
  20. Click OK. All the "Sum of Signal2" labels change to "StdDev of Signal2."

You now how the data desired. You may prefer a setup that shows only one row per category for your data. If so, simply click on the Data header and hold down the mouse button as you slowly move the mouse to the right. As you move the mouse pointer into the Total header area, a small icon near the mouse pointer shows a "change" in the layout. Release the mouse button and you will have only one row for each group in your data.

If you need to change the number of data items in each group, just go back to the data worksheet and change cell E1 to a different value. You can then return to the PivotTable, right click it, and choose Refresh Data.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (2771) applies to Microsoft Excel 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Excel (Excel 2007 and later) here: Calculating Statistical Values on Different-Sized Subsets of Data.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Hiding Graphics

Do you need a printout where graphics can be turned on and off? This tip provides some concrete ways you can get just ...

Discover More

Getting Rid of Numbered Columns

Excel normally refers to columns as A, B, C, etc. It also has a referencing format that allows columns to be referred to ...

Discover More

Generating Double-Digit Random Numbers

Normally you use the RAND and RANDBETWEEN functions to generate random numbers. What if you want to generate random ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (menu)

Only Showing the Maximum of Multiple Iterations

When you recalculate a worksheet, you can determine the maximum of a range of values. Over time, as those values change, ...

Discover More

Matching Formatting when Concatenating

Convert a numeric value to text and you may be surprised by how Excel displays the value. Here's a run-down on exactly ...

Discover More

Separating Names into Individual Columns

If you have a list of names in a column, and you want to separate those names into individual cells, there are several ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] (all 7 characters, in the sequence shown) in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 2 + 2?

There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)


This Site

Got a version of Excel that uses the menu interface (Excel 97, Excel 2000, Excel 2002, or Excel 2003)? This site is for you! If you use a later version of Excel, visit our ExcelTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.