+ Reply to Thread
Results 1 to 12 of 12

average of last 5 in a table

  1. #1
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    140

    average of last 5 in a table

    Hi

    I have a table that i update every week with a new rate of pay, from which i have an automatic calculation of the overall average. How do i have a calculation of the last 5 weeks rate of pay?

    Eg for week 20, if data is in a1:a20, i want the average of a16:a20
    for week 21, if data is in a1:a21, i want the average of a17:a21 etc etc, but automatic calculation

    thanks!

  2. #2
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: average of last 5 in a table

    Try something like

    =AVERAGE(INDEX(A:A,COUNT(A:A)-4):INDEX(A:A,COUNT(A:A)))

  3. #3
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: average of last 5 in a table

    Hi Cutter

    that has returned an error, sorry! I've actually not explained myself correctly aswell sorry. ive attached a bit of the workbook to help explain.

    the formula will need to go in cells AO3, AO4, AO5 and so on. as you will see, there are lots of blank cells but these will be filled in weekly and would like and average of the last 5 entered figures. hope ive explained this better this time!

    thanks
    Attached Files Attached Files

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: average of last 5 in a table

    Try

    Just a slight modification to Cutter's formula...

    =AVERAGE(INDEX(D3:AN3,COUNT(D3:AN3)-4):INDEX(D3:AN3,COUNT(D3:AN3)))

    drag down
    HTH
    Regards, Jeff

  5. #5
    Registered User
    Join Date
    06-18-2012
    Location
    Devon, England
    MS-Off Ver
    Excel 2003 & Excel 2010
    Posts
    10

    Re: average of last 5 in a table

    Hi, Petelomax,
    I've tried Cutter's formula and got it to work fine, you just need to replace every instance of A:A with $D3:$AN3 on row 3. (This can then be dragged down as far as you need it to go:

    =AVERAGE(INDEX($D3:$AN3,COUNT($D3:$AN3)-4):INDEX($D3:$AN3,COUNT($D3:$AN3)))

  6. #6
    Registered User
    Join Date
    06-18-2012
    Location
    Devon, England
    MS-Off Ver
    Excel 2003 & Excel 2010
    Posts
    10

    Re: average of last 5 in a table

    I wasn't just duplicating Jeff's reply - honest! It just took me longer to write it

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: average of last 5 in a table

    And I don't think anybody thought that...

    The crossing of posts happens all the time...

    Good job

  8. #8
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: average of last 5 in a table

    thanks everyone for your replies, this works a treat now

  9. #9
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: average of last 5 in a table

    Hi, just an extension on this, there has to be at least 4 figures in the last 4 columns for this to work, but sometimes there are products with just one rate of pay and it throws up an error

    ive attached a document to help explain this. thanks.
    Attached Files Attached Files

  10. #10
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: average of last 5 in a table

    You need to do the count on a row that is guaranteed to always have something to count - from start to end.
    So, row 2 would be such a row. But it's text, not numeric. So, instead of COUNT() use COUNTA().

    Like this: =AVERAGE(INDEX(D8:AN8,COUNTA(D$2:AN$2)-4):INDEX(D8:AN8,COUNTA(D$2:AN$2))) for cell AO8 and copied throughout

  11. #11
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: average of last 5 in a table

    Hi Cutter

    Thanks very much for this, works a treat! thanks!

  12. #12
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: average of last 5 in a table

    You're welcome. Thanks for the 'star tap'.

+ 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