Calculating an Average within a Date Range

Written by Allen Wyatt (last updated January 15, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


3

Dan has a worksheet that contains information about homes sold in his community. The sheet has a number of columns, two of which are Sale Date and Selling Price. Dan would like to calculate an average sales price for sales made between a starting and ending Sale Date. He could filter the data and then calculate an average, but he would rather just come up with a formula that returned the value. He's not sure how to go about that, however.

There are actually a number of different ways you can get the average you seek. Let's assume, for the sake of example, that you select all the cells that contain the sale dates and give that range the name SaleDate. Further, you define the name SellingPrice to refer to the range that contains the selling prices. Finally, you define cells for StartDate and EndDate (their contents should be self-explanatory). Given this, you could use a formula such as this:

=AVERAGEIFS(SellingPrice, SaleDate, ">=" & StartDate, SaleDate, "<=" & EndDate)

As I said, there are other formulas you could use, as well. Here are just two:

=AVERAGE(IF((SaleDate >= StartDate) * (SaleDate <= EndDate), SellingPrice))
=AVERAGE(FILTER(SellingPrice, ((SaleDate >= StartDate) * (SaleDate <= EndDate))))

Which one should you use? It really doesn't matter in this case; it is entirely up to you. Each returns the exact same result, and you don't need to worry about sorting your data in any particular order.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12809) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021.

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

Digital Signatures for Macros

The security features built into Excel 2002 and 2003 allow you to digitally sign your macros so that users can rest ...

Discover More

Prohibiting Single-Digit Entries in a Cell

The Data Validation capabilities of Excel can be very helpful when you are trying to control what people can enter into a ...

Discover More

Chapter Numbers in Indexes and TOAs

Word allows you to define prefixes for page numbers. These are often used for chapter or section numbers in a large ...

Discover More

Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!

More ExcelTips (ribbon)

Locating a Single-Occurrence Value in a Column

Given a range of cells containing values, you may have a need to find the first value in the range that is unique. This ...

Discover More

Extracting a Pattern from within Text

If you have a large amount of data in a worksheet and you want to extract information from the text that meets certain ...

Discover More

Determining a Zodiac Sign from a Birthdate

If you want to find out the Zodiac sign for a birthdate, there are a number of ways you can do it. This tip provides ...

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 8 - 5?

2022-01-19 18:26:54

Chris

@Sidney Kaine - if you still have questions after reading MS' post, feel free to reach out to me and I can talk you through whatever you're struggling with. Here's my e-mail address that I check a couple times a week to help users with EXCEL questions - reaume17@gmail.com

@Dan (the person who originally asked this question to Allen) - feel free to contact me as well if you have any follow-up questions


2022-01-15 18:09:46

MS

As asked ... Here is an example with cell ranges instead of named ranges. I used a sample of 3 sales.

I put the formula in cell A2. =AVERAGEIFS(B5:B7, A5:A7, ">=" & B1, A5:A7, "<=" & B2)

Cell B1 contains the start date. I used 1/1/2022.

Cell B2 contains the end date. I used 1/10/2022.

Cells A5, A6, and A7 contain the sale dates. I used 1/1/2022, 1/15/2022, and 1/10/2022.

Cells B5, B6, and B7 contain the selling prices. I used 100000, 150000, and 200000.

The formula returns 150000.

Hope this helps.


2022-01-15 12:10:53

Sidney Kaine

Could someone please show the below formula filled in with actual cell references. There are a few things I find confusing, ie if the " need to be added and the spaces within the formula need to be added, etc. A small set of numbers with a completed formula would help me a lot.

=AVERAGEIFS(SellingPrice, SaleDate, ">=" & StartDate, SaleDate, "<=" & EndDate)

Thank you,
Sidney


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.

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.