+ Reply to Thread
Results 1 to 6 of 6

if and statement with average return

  1. #1
    Registered User
    Join Date
    07-07-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    4

    if and statement with average return

    hi - from the following data set example, i would like to return the average of column C if the criteria meets columns A & B. for example. if column A = 7 and column B = 2011, provide the average return of column C. result should be 42.113.... please help. any and all is most appreciated

    best regards

    8 2011 39.49073466
    8 2011 40.10209175
    7 2011 41.21885669
    7 2011 40.36205606
    7 2011 39.45128469
    7 2011 41.65746244
    7 2011 41.20755325
    7 2011 43.41200631
    7 2011 44.34023394
    7 2011 44.24648197
    7 2011 43.49374838
    7 2011 44.51996125
    7 2011 40.87890875
    7 2011 43.80680931
    7 2011 42.25107419
    7 2011 38.73625294
    6 2011 42.39128759
    6 2011 42.68405703
    6 2011 43.03057088
    6 2011 40.92321709

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: if and statement with average return

    In Excel 2003, one way:

    =SUMPRODUCT((A2:A21=7)*(B2:B21=2011)*(C2:C21))/SUMPRODUCT((A2:A21=7)*(B2:B21=2011))

    I'm sure there must be a neater option ... but it works.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    07-07-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: if and statement with average return

    thanks you very much for your help - most appreciated

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: if and statement with average return

    You're welcome.

    If this has answered your question, please mark your thread as solved. Please see my signature for details or the FAQ.

    Regards

  5. #5
    Registered User
    Join Date
    07-07-2011
    Location
    london
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: if and statement with average return

    hi again - it hasnt yet unfortunately. the set of data i submitted as an example is small comparative to the actual dataset. the actual dataset grows on a daily basis, so i would like to ideally have your formula read: SUMPRODUCT((A:A=7)*(B:B=2011)*(C:C))/SUMPRODUCT((A:A=7)*(B:B=2011)), but i have either #num or #ref returned.... apologies for further work, but any suggestions?

    many thanks again

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,510

    Re: if and statement with average return

    You can't use entire column references in Excel 2003. You can, but shouldn't, in Excel 2007.

    Effectively, you are are creating a matrix of 65000+ rows ... and Excel is unhappy with that.

    As I said, you can do it in Excel 2007 but it's likely to be very slow.

    You could, perhaps, create some dynamic named ranges for the values in columns A, B and C.

    Regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1