+ Reply to Thread
Results 1 to 6 of 6

Average in rows

  1. #1
    Registered User
    Join Date
    03-15-2007
    Posts
    53

    Average in rows

    I have included a workbook with this. In column B what I need is the average of the last 5 games a team has played. C being there first game. So for example in row 2 I need the average of air force for games 9 thru 13 so column J thru O. Whereas in row 3 I need Akron for games 7 thru 11, I thru M. Now in row 19 for Brown, I need to average 2, 3, 8,9 and 10 because there is no data for 4 thru 7.
    Attached Files Attached Files

  2. #2
    Forum Contributor snasui's Avatar
    Join Date
    07-15-2007
    Location
    Songkhla, Thailand
    MS-Off Ver
    2010, 365
    Posts
    167
    Try this,

    B2 on sheet1

    HTML Code: 
    =AVERAGE(OFFSET(D2,0,LARGE(IF(ISNUMBER(D2:AA2),COLUMN(D2:AA2)-COLUMN(D2)),5),,COLUMNS(D2:AA2)-LARGE(IF(ISNUMBER(D2:AA2),COLUMN(D2:AA2)-COLUMN(D2)),5)))
    Ctrl+Shift+Enter and copy down

    Hope this helps.
    Last edited by shg; 11-30-2007 at 11:59 PM. Reason: quote deleted

  3. #3
    Registered User
    Join Date
    03-15-2007
    Posts
    53
    This works great thanks so much. I have a small problem which won't matter as the season gets later but early on when I don't have enough games. For example at team that has played only four games it returns an error. Just wondering of the code could be altered for this. Thanks again. I was going to try to write some kind of long if statement with some kind of counter. Your way much easier.

  4. #4
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,676
    Assuming you always have the correct number of games played shown in column C (perhaps use the formula =COUNT(D2:AA2) in C2 copied down) try this formula in B2, confirmed with CTRL+SHIFT+ENTER and copied down

    =AVERAGE(IF(COLUMN(D2:AA2)>=LARGE(IF(D2:AA2<>"", COLUMN(D2:AA2)),MIN(5,C2)),IF(ISNUMBER(D2:AA2),D2:AA2)))

  5. #5
    Forum Contributor snasui's Avatar
    Join Date
    07-15-2007
    Location
    Songkhla, Thailand
    MS-Off Ver
    2010, 365
    Posts
    167
    Another

    Please Login or Register  to view this content.
    Ctrl+Shift+Enter

    Hope this helps.

  6. #6
    Registered User
    Join Date
    03-15-2007
    Posts
    53
    Thanks a lot guys :P

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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