Excel running average

How to Calculate Running Average in Excel

Introduction

Knowing how to calculate running average in Excel can save you a lot of time and energy.

Sample Data

Imagine your Microsoft Excel data consists of “Days of Accidents”. For each day on this list there has been one accident:
How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
As you can see, not all days are listed. There have been no accidents on the days that are not on this list.
If a day is listed more than once it’s because more than one accident happened on that day, each represented by a separate row.

PROBLEM

Now your manager asks you to draw a chart with the following characteristics:

  1. The chart should display the data by WEEKS and not by days. Thus you need to aggregate the daily data into weeks.
  2. She needs you to report the TOTAL NUMBER OF ACCIDENTS for each week.
  3. She also wants you to report the RUNNING AVERAGE for each week defined as the CUMULATIVE TOTAL OF NUMBER OF ACCIDENTS up to and including that specific week, divided by, the CUMULATIVE TOTAL OF NUMBER OF WEEKS up to and including that specific week.

SOLUTION

STEP 1 – First we need to get rid of the “holes” in our list of days.

We need to select and then delete all the blank cells.

  1. Select Column A.
  2. Click F5 to display the GO TO dialog box.
  3. Click SPECIAL to display the GO TO SPECIAL dialog box.
  4. Select BLANKS radio button.
  5. Click OK to select all the blank cells in the column.
  6. Right click on any of the selected blank cells to display the DELETE dialog box.
  7. Select ENTIRE ROW radio button:
    How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
  8. Click OK to delete all the blank cells (rows).

STEP 2 – We need to count the number of accidents for each day.

Enter the following formula into Cell B2:
=COUNTIF($A$2:$A$28,A2)
This will give you the total count for the dates. Repeat the procedure for all the other cells to get the following:
How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
STEP 3 – Removing the duplicate cells.

To remove the repeating DATE cells you first need to remove the formulas from Column B since you’d like to remain the date COUNT the same and not revert to “1” when only one of each date group is left in the worksheet.

  1. Copy all the cells and paste them in another location by selecting HOME > Paste > Values & Number. The result looks exactly the same but this time the COUNT column has no formula in it:
    How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
  2. Select all the newly pasted columns.
  3. On the DATA tab click the REMOVE DUPLICATES button to display the REMOVE DUPLICATES dialog box:
    How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
  4. Click OK to get the CONFIRMATION message:
    How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
  5. Click OK to close the message box.

STEP 4 – Aggregating Data into Weeks

To perform this step, we first need to create a PIVOT TABLE.
Select all the cells. On the INSERT TAB click the PIVOT TABLE button to display the CREATE PIVOT TABLE dialog box:
How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
After selecting either the “New Worksheet” or “Existing Worksheet” option to place your table at, click OK. If you select the same worksheet, select a cell for the pivot table’s upper left corner.
At the PIVOT TABLE FIELD LIST pane. First check the COUNT check-box to populate the VALUES quadrant, then the other check-box to populate the ROWS quadrant:
How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
Your PIVOT TABLE is created:
How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
Now, select any date cell, right-click on it, and from the pop-up menu select GROUP to display the GROUPING dialog box:
How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
Select DAYS as grouping criterion and select 7 for Number of Days and click OK. Now your data is aggregated by WEEKS:
How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
STEP 5 – Calculate the RUNNING AVERAGE in Excel.

To calculate running averages, add cell values cumulatively from top down and divide them by the number of weeks corresponding to that cell.
For example, the second running average value is calculated as (6 + 3)/2 and so forth.
Here is the result:
How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
NOTE! Before the fun begins, we need to CONVERT pivot table to a SIMPLE TABLE. Select the pivot table and paste it somewhere else on the same worksheet. The result looks the same but will yield a correct chart with the RUNNING AVERAGES values. Otherwise you will not be able to generate bars for the RUNNING AVERAGES.

STEP 6 – Generate the chart

Now begins the FUN PART!
Select the whole (newly pasted) simple table (NOT the previous pivot table). Then from the INSERT TAB select 2-D CLUSTERED COLUMN CHART:
How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
This chart is good but we want it to display the RUNNING AVERAGES as a TREND LINE. So we need to change the ORANGE frequency bars into a trend line.

  1. Select any of the orange bars and right click to display a pop-up menu.
  2. From the menu select CHANGE SERIES CHART TYPE to display the CHANGE CHART TYPE dialog box.
  3. At the bottom pane, for the RUNNING AVE field, select LINE type from the drop-down menu, then click OK.

Here is the final CHART:
How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel
By playing around with various DESIGN options (like CHART STYLES and QUICK LAYOUT options) you can change the appearance of your chart and add additional information. Feel free to experiment with different options. Here is one such improved chart:
How to Count the Number of Days with an Incident and Chart with Running Averages in MS Excel

MORE INFO

How to Count the Number of Days with  Incident and Chart with Running Averages in MS Excel
How to Use SUMIF Conditional SUM Function in MS Excel 2010
How to Aggregate in MS Excel Daily Data into Weekly, Monthly etc. Data