How to Count the Average Between Two Dates in Excel
In our daily work, we usually have the problem of counting the average of a period. If the given dates are continuous, we can handle this situation very well, and if the dates are discontinuous, how do we count the average for different periods? In this article, we will use some examples to show you how to count the average for two dates by Average formula in different situations.
Table of Contents
Count the Average Between Continuous Dates
First prepare a table with given dates and sales.
You can see the given dates are continuous, so we can count average by Average formula directly.
Step 1: In B7, enter the formula =AVERAGE(B2:B4) to count the average between dates 1/28/2019
and 3/28/2019
.
Step 2: Click Enter to get the result.
Count the Average Between Discontinuous Dates
If in above table the dates are discontinuous and unordered, how can we count the average of sales? See screenshot below.
You can follow below steps to count the average for two discontinuous dates.
Step 1: Prepare another table to save the Start Date, End Date and Average.
Step 2: In Start Date enter the start date of the period you want to count the average. In End Date enter the end date of the period you want to count the average. For example, we count the average for period 2/28/2019
and 4/28/2019
.
Step 3: In Average, enter the formula =AVERAGE(IF((A2:A7>=B10)*(A2:A7<=B11),B2:B7)).
In above formula, A2:A7 is the given date range, B10 is the start date, B11 is the end date, B2:B7 is the sales range.
Step 4: After entering the formula, click Ctrl + Shift + Enter
to get the result.
Check the formula bar, you can find the formula is displayed as below. That’s an array formula.
Notes:
1. In step 4, if we just click Enter after entering the formula, then we will get an error here. That’s because above formula is an array formula.
2. If we just want to use a normal formula to count the average and click Enter to get the result, we can use below formula =SUMPRODUCT(–(A2:A7>=B10),–(A2:A7<=B11),B2:B7)/SUMPRODUCT(–(A2:A7>=B10),–(A2:A7<=B11)). We can get the same result.
Related Functions
- Excel SUMPRODUCT function
The Excel SUMPRODUCT function multiplies corresponding components in the given one or more arrays or ranges, and returns the sum of those products.The syntax of the SUMPRODUCT function is as below:= SUMPRODUCT (array1,[array2],…)… - Excel IF function
The Excel IF function perform a logical test to return one value if the condition is TRUE and return another value if the condition is FALSE. The IF function is a build-in function in Microsoft Excel and it is categorized as a Logical Function.The syntax of the IF function is as below:= IF (condition, [true_value], [false_value])…. - Excel AVERAGE function
The Excel AVERAGE function returns the average of the numbers that you provided.The syntax of the AVERAGE function is as below:=AVERAGE (number1,[number2],…)….