MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old May 8th, 2002, 09:32 AM   #1
mapakunk
New Member
 
Join Date: May 2002
Posts: 40
Default

I would like to average a range of numbers if the dates are between 4 weeks ago and today? any ideas.
The dates are in column d12:d100 and the values are in column p12:p100
any help would be greatly appreciated. Also if I can do this without VBA I would appreciate it beacuse I do not know VBA!

As far as I know there is no averageif function.

_________________
mapakunk

[ This Message was edited by: mapakunk on 2002-05-16 09:50 ]
mapakunk is offline   Reply With Quote
Old May 8th, 2002, 09:41 AM   #2
Steve Hartman
Board Regular
 
Steve Hartman's Avatar
 
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
Default

Quote:
I would like to average a range of numbers if the dates are between 4 weeks ago and today? any ideas.
The dates are in column d12:d100 and the values are in column p12:p100
=AVERAGE(IF(D12:D100>TODAY()-28,P12:P100))


This is an array formula and must be entered into the cell by pressing Ctrl-Shift-Enter at the same time.






[ This Message was edited by: Steve Hartman on 2002-05-08 11:43 ]
Steve Hartman is offline   Reply With Quote
Old May 8th, 2002, 09:45 AM   #3
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Quote:
On 2002-05-08 08:32, mapakunk wrote:
I would like to average a range of numbers if the dates are between 4 weeks ago and today? any ideas.
The dates are in column d12:d100 and the values are in column p12:p100
any help would be greatly appreciated. Also if I can do this without VBA I would appreciate it beacuse I do not know VBA!

As far as I know there is no averageif function.
=SUMPRODUCT((D12:D100>=A1-28)*(D12:D100<=A1),P12:P100)/MAX(1,SUMPRODUCT((D12:D100>=A1-28)*(D12:D100<=A1)))

where A1 holds the formula: =TODAY().

Aladin
Aladin Akyurek is offline   Reply With Quote
Old May 8th, 2002, 09:49 AM   #4
mapakunk
New Member
 
Join Date: May 2002
Posts: 40
Default

This seems to pick the right columns, however the values this would be are about 9000 and the average that is returned is 1384.80?? I copied your formula, pasted it, deleted the space, and rpessed Ctrl+shft+enter at the end to make it an array formula maybe there is something I should be telling you that I'm not??

Thanks for the SPEEDY reply!!!!
mapakunk is offline   Reply With Quote
Old May 8th, 2002, 09:51 AM   #5
mapakunk
New Member
 
Join Date: May 2002
Posts: 40
Default

Aladin,

That was the ticket! Thank you very much!
This is one to scribble down in the back of my excel2000 bible!!!!

:>
mapakunk is offline   Reply With Quote
Old May 8th, 2002, 10:09 AM   #6
Steve Hartman
Board Regular
 
Steve Hartman's Avatar
 
Join Date: Feb 2002
Location: Houston,Texas
Posts: 418
Default

Quote:
On 2002-05-08 08:49, mapakunk wrote:
This seems to pick the right columns, however the values this would be are about 9000 and the average that is returned is 1384.80?? I copied your formula, pasted it, deleted the space, and rpessed Ctrl+shft+enter at the end to make it an array formula maybe there is something I should be telling you that I'm not??
Nope, something I should have told you. Thanks to the edit function, the formula you tried was not the right one. I realised after I posted it that the "less than" should have been a "greater than" and I edited the post. Unfortunately it was after you had seen the original.
Steve Hartman is offline   Reply With Quote
Old May 8th, 2002, 10:41 AM   #7
IML
MrExcel MVP
 
Join Date: Feb 2002
Location: Denver, CO
Posts: 1,744
Default

I think you could also go with

=SUMIF(D12:D100,">="&TODAY()-28,P12:P1002)/COUNTIF(D12:D100,">="&TODAY()-28)

if you notice any performance issues.

good luck

edited for the cool denominator trick
=SUMIF(D12:D100,">="&TODAY()-28,P12:P1002)/MAX(COUNTIF(D12:D100,">="&TODAY()-28),1)

[ This Message was edited by: IML on 2002-05-08 09:43 ]
IML is offline   Reply With Quote
Old May 8th, 2002, 11:02 AM   #8
Aladin Akyurek
MrExcel MVP
 
Aladin Akyurek's Avatar
 
Join Date: Feb 2002
Location: The Hague
Posts: 50,317
Default

Quote:
On 2002-05-08 09:41, IML wrote:
I think you could also go with

=SUMIF(D12:D100,">="&TODAY()-28,P12:P1002)/COUNTIF(D12:D100,">="&TODAY()-28)

if you notice any performance issues.

good luck

edited for the cool denominator trick
=SUMIF(D12:D100,">="&TODAY()-28,P12:P1002)/MAX(COUNTIF(D12:D100,">="&TODAY()-28),1)

[ This Message was edited by: IML on 2002-05-08 09:43 ]
Makapunk,

I'd suggest using the above SUMIF version. & it's not (just) a performance issue as Ian modestly puts. I just overlooked the fact that today is not a fixed date, so there is no need to take that as a second condition which necessitated SUMPRODUCT (you might still keep it on the back of Excel bible, though).

Regards,

Aladin

[ This Message was edited by: Aladin Akyurek on 2002-05-08 10:03 ]
Aladin Akyurek is offline   Reply With Quote
Old May 8th, 2002, 11:31 AM   #9
mapakunk
New Member
 
Join Date: May 2002
Posts: 40
Default

I guess i could use the sumproduct formula, keeping today() in A1, and then change that date if I wanted to see an average for 4 weeks from any given date.

Thanks for the help, this BB is VERY Helpful.
especially because it is free. Maybe someday I'll be able to return the favor...

Tanks everybody,

mapakunk
mapakunk is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 04:07 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes