Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, and 2013. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Calculating Averages by Date.

# Calculating Averages by Date

by Allen Wyatt
(last updated October 2, 2019)

Suppose that you have a huge worksheet that contains all the rainfall readings for a given locale for the past hundred years or so. In cells A2:A37987 you have the dates, 1 January 1903 through 31 December 2006. In cells B2:B37987 you have the measurements for each date. Further, some of the measurements can be zero (if there is no rainfall for the day) or blank (if no reading was taken that particular day). With all this information, you want to calculate the average historic rainfall for any given day of the year.

One solution involves the use of array formulas, as detailed here:

1. Select all the cells in column A that contain dates, and assign this range the name Dates.
2. Select all the corresponding cells in column B; these contain the rainfall data for the dates in column A. Assign this range the name Rainfall.
3. In column D, starting in cell D2, place all the days of the year. You should end up with D2 through D366 filled with dates.
4. In cell E2, enter the following array formula (terminate the formula by pressing Shift+Ctrl+Enter). The result of the formula is the sum of all the cells in the Rainfall range, for the date specified in cell D2.
5. ```=SUM((MONTH(Dates)=MONTH(D2))*(DAY(Dates)=DAY(D2))*Rainfall)
```
6. In cell F2, enter the following array formula (terminate the formula by pressing Shift+Ctrl+Enter). The result of the formula is the number of cells in the Rainfall range, for the date in cell D2, that have a value in them.
7. ```=SUM((MONTH(Dates)=MONTH(D2))*(DAY(Dates)=DAY(D2))*(Rainfall<>""))
```
8. In cell G2, enter the following regular formula. This is your average for the date in cell D2.
9. ```=IF(F2<>0,E2/F2,"")
```
10. Select the range E2:G2 and copy down for all the dates shown in column D.

This approach works, but it takes quite a while to calculate. This is because you effectively entered 730 array formulas, each checking over 37,000 cells. This is a lot of work, and consequently it may appear like your machine has "hung" after you complete step 7. It has not hung; it will just take it a while to complete the calculations.

To decrease the number of calculations that must be performed, you can use a variation on the above steps. Follow steps 1 through 3, as noted, and then place the following array formula into cell E2:

```=AVERAGE(IF((Dates<>0)*(Rainfall<>0)*(MONTH(Dates)=MONTH(D2))*(DAY(Dates)=DAY(D2)),Rainfall))
```

You can then copy the formula down for all the dates shown in column D. The result of this formula is the actual average rainfall, the same as had been shown in column G in the previous approach.

You can reduce the calculation overhead even further by simply getting rid of all the table that calculates the averages for every day of the year. With your dates and rainfall in columns A and B, follow these steps:

1. Select all the cells in column A that contain dates and assign this range the name Dates.
2. Select all the corresponding cells in column B; these contain the rainfall data for the dates in column A. Assign this range the name Rainfall.
3. In cell D2, place the date for which you want to check the average rainfall. (The year isn't important; only the month and day are used in the calculation.)
4. Enter the following formula into cell E2:
```=AVERAGE(IF((Dates<>0)*(Rainfall<>0)*(MONTH(Dates)=MONTH(D2))*(DAY(Dates)=DAY(D2)),Rainfall))
```

That's it. Now, you can change the date in cell D2 as desired, and cell E2 will always indicate the average rainfall for that date. The formula in cell E2 is the same as the formula used in the last approach; the difference is that you aren't calculating it for all the days in a year, and thus the calculation is done much quicker.

Another approach involves the use of Excel's filtering capabilities. Before you can use them properly, however, you must create a column that shows only the month and day for each date in your data. Use this formula in cell C2:

```=MONTH(A2) & "-" & DAY(A2)
```

Now, turn on AutoFiltering (display the Data tab on the ribbon | Sort & Filter group | Filter) and use the drop-down list at the top of the new column to select the date for which you want an average. You then use the following formula, placed in any cell desired, to show the average rainfall for the selected date:

```=SUBTOTAL(1,B:B)
```

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (10319) applies to Microsoft Excel 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Excel here: Calculating Averages by Date.

##### 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

Grouping Drawing Objects

Drawing objects are easily added to a document. You can group these objects so they are easier to manage by following the ...

Discover More

Changing a Folder's Color

Folders are a great organizational tool in Drive. You can individualize folders not just by name, but also by changing ...

Discover More

Displaying the User Name in the Status Bar or Title Bar

Sometimes it can come in handy to know who the current computer user is, as far as Word is concerned. This tip presents ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

##### More ExcelTips (ribbon)

Converting European Dates to US Dates

Those in Europe use a date format that is different than those in the US; this is not news. But what if you need to ...

Discover More

Converting Coded Dates into Real Dates

Sometimes the format in which you receive data is not the same format that would be optimal for Excel. For instance, you ...

Discover More

Days Left in the Year

Sometimes it is handy to know how many days are left in the current year. This tip provides a quick formula that ...

Discover More
##### Subscribe

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

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}] 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 nine more than 2?

2019-10-02 11:37:13

gerdami

I prefer to use AVERAGEIFS(). I make a list/table "Table1", I add a column "MMDD" that computes =TEXT([@Date],"MM-DD"). To get the average of rainfall on a 28 February I use =AVERAGEIFS(Table1[RainFall],Table1[RainFall],"<10E69",Table1[MMDD],"=02-28"). The criteria "<10E69" will get rid of any non-number data, including #N/A.

2016-06-12 14:44:08

paul

Correction...I discovered a several bad points buried in my 38,262 records. All is well.

2016-06-12 13:16:09

paul

all of the array formulas discuss on this page return negative (impossible) results for rainfall in Excel 2016). i.e. none of them work correctly.

2015-11-15 13:25:06

callum

How can I include the year into this function. For example may data is from 2004 to 2008. I want an average for 5th may 2005 not the 5th may from each year?

##### This Site

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