+ Reply to Thread
Results 1 to 8 of 8

Find average of last 4 non zero numbers

  1. #1
    Registered User
    Join Date
    11-27-2008
    Location
    Canada
    Posts
    6

    Find average of last 4 non zero numbers

    Hi I am trying to figure out how to take the average of the last 4 "non-zero" numbers in a series of values.

    The sheet looks something like this, numbers are all in one row:

    7 , 7 , 7 , 7 , Total = 28 , 8 , 8 , 8 , 8 , Total = 32 , 0 , 0 , 0 , 0 , Total = 0 , 8 , 8 , 8 , 8 , Total = 32 , 7 , 7 , 7 , 7 , Total = 28 , 8 , 8 , 8 , 8 , Total = 32 , 0 , 0 , 0 , 0 , Total = 0 , 8 , 8 , 8 , 8 , Total = 32

    I'm looking for a formula that will look at all the last few totals (starting from the end) and take an average of the last 4 totals that were > 0. In this case it would average {32, 32, 28, 32} ignoring the 0 total.

    Any help is appreciated... thanks kindly. Let me know if there is anything else I need to clarify.
    Last edited by Infinity99; 11-30-2008 at 11:17 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464
    Hi, and welcome to the forum.

    Does the 5th Total value cell in each block contain the characters "Total = " as well as the total number, or just the total number itself?

    Rgds

  3. #3
    Registered User
    Join Date
    11-27-2008
    Location
    Canada
    Posts
    6
    All the total values are just values. There is no text in the row, so it'd be 7 , 7 , 7, 7 , 28 , 8 , 8 etc.

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Find average of last 4 non zero numbers

    With
    A1:AN1 containing your posted values....

    This formula returns the average of the last 4 totals that are greater than zero
    Please Login or Register  to view this content.
    In your example, the formula returns: 31
    (the average of 32,28,32,32)

    Is that something you can work with?
    Last edited by Ron Coderre; 11-27-2008 at 11:43 AM. Reason: Change the formula location from AM1 to AO1
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  5. #5
    Registered User
    Join Date
    11-27-2008
    Location
    Canada
    Posts
    6
    Hi Richard/Ron, thanks for your response

    Does this suggested formula take the 4 largest numbers in the array or does it take the last 4 (non-zero) values in the array? (i'm not familiar with the LARGE function yet)

    I have since reorganized my data so it may be simpler to create the formula.

    It now looks like this (just totals):

    28 , 32 , 0 , 32 , 28 , 32 , 0 , 32

  6. #6
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Find average of last 4 non zero numbers

    To answer your first question....The formula I posted averages the LAST 4 totals that are greater than zero.

    Regarding the new scenario of only consecutive totals...
    With
    A1:H1 containing these values
    28 , 32 , 0 , 32 , 28 , 32 , 0 , 32

    This formula returns the average of the last 4 totals that are greater than zero
    Please Login or Register  to view this content.
    In the above example, the formula returns: 31
    (the average of 32,28,32,32)

    Does that help?

  7. #7
    Registered User
    Join Date
    11-27-2008
    Location
    Canada
    Posts
    6
    Ron, you sir are a gentleman and a scholar.

    I hope I can help someone on this board as much as you just did. If you're in the Toronto area, your next drink is on me.

  8. #8
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    I'm glad I could help

    ...thanks for the kind words (and the offer).

+ 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