+ Reply to Thread
Results 1 to 21 of 21

Average last 10 entries (ignoring zeros)

  1. #1
    Registered User
    Join Date
    06-02-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    5

    Average last 10 entries (ignoring zeros)

    Hi, I'm hoping there's someone out there that can help me with this one.

    I'm trying to get an average of the last 10 cell inputs, ignoring any zeros. The formula is in (I2).

    I have a table of data where entries are inputted each week, within a date range of 2017 to 2016 (the first cell B10 is the last week in Dec 2017 and the last cell DA10 corresponding to first week in Jan 2016) . The totals are on the same row B10:DA10 and are represented in weeks. At present data has been inputted to June 2016, but cells after that (to Dec 2017) remain empty. There are 62 week columns in total.

    Whilst I'm able to find the average of the inputs, I'm unable to extrapolate the average value of just the last 10 cells (weeks) ignoring the empty date range which is yet to be inputted (i.e. July 2016 to Dec 2017). I've tried this but no joy =AVERAGE(OFFSET(B10,,COUNT(B10:DA10)-10))

    Any assistance will be greatly appreciated!

    Cheers in advance.
    Attached Files Attached Files
    Last edited by Boris179; 06-02-2016 at 08:09 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,213

    Re: Average last 10 entries (ignoring zeros)

    Welcome to the forum! Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    04-04-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    89

    Re: Average last 10 entries (ignoring zeros)

    Use this formula =AVERAGEIF(A2:A25,">0")
    Change the Row/Column accordingly

  4. #4
    Registered User
    Join Date
    06-02-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    5

    Re: Average last 10 entries (ignoring zeros)

    That's great thanks, but I'm also trying to average just the last 10 entriers.

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,213

    Re: Average last 10 entries (ignoring zeros)

    The attached sheet is no use as it draws data from another sheet that we don't have. Create a copy of it with the values rather than formulae, please.

  6. #6
    Registered User
    Join Date
    06-02-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    5

    Re: Average last 10 entries (ignoring zeros)

    New version attached.
    Attached Files Attached Files

  7. #7
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Average last 10 entries (ignoring zeros)

    Try this array formula

    =AVERAGEIF(DA10:INDEX(10:10,LARGE(IF(B10:DA10>0,COLUMN(B10:DA10)),10)),">0")

    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

  8. #8
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Average last 10 entries (ignoring zeros)

    Quote Originally Posted by AliGW View Post
    The attached sheet is no use as it draws data from another sheet that we don't have.
    Ali, in other threads where the data consistency is less predictable, I would agree with you, however the sample sheet gives enough information to work from in this instance, thinking logically we know that the formulas in row 10 must return integers, so substituting some appropriate values is adequate to test a formula.

    I used =RANDBETWEEN(0,3) in B10:DA10 to produce suitable data for testing.

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,213

    Re: Average last 10 entries (ignoring zeros)

    Quote Originally Posted by jason.b75 View Post
    Ali, in other threads where the data consistency is less predictable, I would agree with you, however the sample sheet gives enough information to work from in this instance, thinking logically we know that the formulas in row 10 must return integers, so substituting some appropriate values is adequate to test a formula.

    I used =RANDBETWEEN(0,3) in B10:DA10 to produce suitable data for testing.
    Maybe for you, Jason, but it wasn't for me. Over to you!

  10. #10
    Registered User
    Join Date
    06-02-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    5

    Re: Average last 10 entries (ignoring zeros)

    Jason - thanks for this. It works, but this shows the first 10 inputs, rather than the last 10 (which i need). The data is inputted from right to left.

    Thanks again for your help on this one.

  11. #11
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Average last 10 entries (ignoring zeros)

    Ali, my apologies if that came across as harsh criticism, that wasn't how it was intended. Thinking that you have an interest in learning and understanding, I was trying (badly) to point out that it is sometimes, but not always possible to work without detailed and accurate samples.

    Rather than cluttering the thread too much with a side discussion, I'll send you a p.m. later to guide you through what I was thinking, never know when you might be able to use it

    Boris, I looked at what was needed but didn't read the dates in the rows above, just assumed (incorrectly) that the last entries would be on the left.

    In between slices of rather chewy humble pie, I was able to reverse the formula.

    =AVERAGEIF(B10:INDEX(10:10,SMALL(IF(B10:DA10>0,COLUMN(B10:DA10)),10)),">0")

    Still needs to be array confirmed.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    81,213

    Re: Average last 10 entries (ignoring zeros)

    Jason - don't get me wrong! I can see your reasoning now, but to be honest, this one had me stumped!!!

  13. #13
    Registered User
    Join Date
    06-02-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    5

    Re: Average last 10 entries (ignoring zeros)

    Jason sir, you are a wizard!

    Thank you!

  14. #14
    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,496

    Re: Average last 10 entries (ignoring zeros)

    Simple formula, not Array Entered:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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


  15. #15
    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,496

    Re: Average last 10 entries (ignoring zeros)

    The data is inputted from right to left.
    Sorry, missed that too

  16. #16
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Average last 10 entries (ignoring zeros)

    Looking at Trevor's formula, I'm wondering if I had the wrong idea of last 10 ignoring zeros.

    The formula that I suggested averages the last 10 non-zero values, so with a single zero in the last 10, the formula would look at the last 11 values and exclude the zero, rather than average the 9 non zero values in the last 10 (which Trevor's formula appears to do).

    Could you confirm which of us is on the right track.

  17. #17
    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,496

    Re: Average last 10 entries (ignoring zeros)

    @jason: thanks for asking the question; I was wondering that but guessed you had it right. My formula to average the first 10 from the left would be much simpler ... but the answer probably isn't what is wanted.

  18. #18
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Average last 10 entries (ignoring zeros)

    I'm going to throw in a revised array formula based on latest observations.

    =AVERAGEIF(B10:INDEX(B10:DA10,IFERROR(MATCH(2,1/ISBLANK(B10:DA10)),0)+10),">0")

    @Trevor: I'll leave you to revise your formula if it's needed, I can see what you've done with it, but I don't like cannibalizing other peoples methods.

  19. #19
    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,496

    Re: Average last 10 entries (ignoring zeros)

    @jason: no worries, I think I'm done here. Hack away

    I think you have all the options nailed.

    One thought, given that data is being entered from the left, I'm guessing there will be a point where the OP is going to insert some columns ... And I'm not sure how the OP would cope with adapting the formula.

    Could it (easily) be made to cater for full row references?
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  20. #20
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Average last 10 entries (ignoring zeros)

    That same thought did cross my mind, but I thought I would leave that pending confirmation from the OP.

    One of the consequences of entering data backwards.

    I guess you could just replace the 3 references to B2: with INDEX(10:10,2): but it does start looking a bit messy when you start doing things like that.

  21. #21
    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,496

    Re: Average last 10 entries (ignoring zeros)

    ... but it does start looking a bit messy when you start doing things like that.
    Yes, but it would make the address static, and it would work

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Sum Small formula ignoring zeros
    By Newmord in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-19-2016, 05:48 AM
  2. Min formula ignoring zeros.
    By jvandermolen in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-08-2014, 12:33 PM
  3. [SOLVED] Rolling average with data in a row using only last 10 entries ignoring blanks
    By Lasers Reef in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-22-2013, 09:37 PM
  4. Ignoring values with zeros
    By exdox77 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-06-2013, 10:32 PM
  5. [SOLVED] Average for non-consecutive cells excluding zeros (even when they all contain zeros)
    By pao13 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-05-2012, 04:32 PM
  6. Median if - ignoring zeros
    By adame in forum Excel General
    Replies: 1
    Last Post: 05-24-2012, 11:57 AM
  7. [SOLVED] Averaging, ignoring zeros
    By Mark in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-28-2005, 07:06 PM

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