Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile average based on date range 2

Status
Not open for further replies.

eggohead

Technical User
Oct 19, 2003
25
US
Hello,

Many Kudos to the folks helping in this forum. I have one more issue revolving around dates. I need to get the average of a column based on a date range.

I used the followiong formula to retrieve a row count of dates that meet date criteria in B2 and B3.

=SUMPRODUCT(--(DATES!L2:L148>=B2)*((DATES!L2:L148<=B3)))

I now need a similar formula that will average data in the next column M (conains number values) for the same date criteria in B2 and B3.

Any suggestions?

Thanks,

 



Hi,

Use the COUNT function to count numeric entries. Use COUNTA to count ANY entry.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Skip,

I dont need to count. I need to average the values that fall between B2 and B3. Or I guess I could sum those values then divide by the fomula I listed.
 



{quote]I dont need to count.[/quote]

Maybe I misunderstood your question.

How will your average be calculated? Please post an example based on data from these two columns.

Please be clear, concise and complete.

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
You don't just want to count the number of 'hits', you want to sum them. That can easily be achieved by adding a group to your SumProduct:

[tab]=SUMPRODUCT(--(Dates!L2:L148>=B2) * (Dates!L2:L148<=B3) * (Dates!L2:L148))
(I also removed extra parentheses around your second part of the formula)

Putting that together with the formula you were already using:

=SUMPRODUCT(--(Dates!L2:L148>=B2) * (Dates!L2:L148<=B3) * (Dates!L2:L148)) / SUMPRODUCT(--(DATES!L2:L148>=B2)*(DATES!L2:L148<=B3))

Because that will most likely return a value with decimals you might want to wrap that formula in another. Either INT(...), ROUND(...) or maybe DATEVALE(...) depending on what date you want returned.

[tt][blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 
OK

I imagine the formula will be similar to the following one you provided but use another function to average or sum. All of the variables are the same the only difference is its now column M and the function is different.

=SUMPRODUCT(--(DATES!L2:L148>=B2)*((DATES!L2:L148<=B3)))

Column M contains data that needs to be averaged between the date values in B2 and B3( greather than B2 but less than B3):

6.57
6.33
0
0
0
93.97
9.57
8.62
15.92
0
9.13
etc.

Hope this makes sense.
 
Ah, then change my last formula to:

[tab]=SUMPRODUCT(--(Dates!L2:L148>=B2) * (Dates!L2:L148<=B3) * (Dates!M2:M148)) / SUMPRODUCT(--(DATES!L2:L148>=B2)*(DATES!L2:L148<=B3))

[tt][blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ 181-2886 before posting.
 




so maybe its something like...
[tt]
=SUMPRODUCT(--(Dates!L2:L148>=B2) * (Dates!L2:L148<=B3) * (Dates!M2:M148))/WHAT
[/tt]
the WHAT could be the SUM of the values in column M

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top