+ Reply to Thread
Results 1 to 16 of 16

Average last 3 non-contiguous, non-zero values

  1. #1
    Registered User
    Join Date
    05-08-2015
    Location
    MI, US
    MS-Off Ver
    2013 pro
    Posts
    7

    Average last 3 non-contiguous, non-zero values

    I have a sheet where i need to average values of 3 non-contiguous cells (actually creating handicaps for a golf league at work). That in and of itself isn't hard. Where the problem comes in--and where I can't seem to wrap my head around this--is that if the value is 0 then I need to move on to the next non-zero week and use that. For example, if my scores for the first 6 weeks are 74, 0, 0, 70, 59, and 77 and I want to get the average for week 6 then I need to average b10, b4, and b2. The kicker is that I can only use a maximum of 3 scores. I can't figure out how to do ths for the life of me... The layout for the values is this:
    Please Login or Register  to view this content.
    the final formula should look like:
    Please Login or Register  to view this content.

  2. #2
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Average last 3 non-contiguous, non-zero values

    Seems to be confusing...
    Could you attach a sample file with results manually mocked up??
    You can attach a sample workbook by clicking on "Go Advanced" button at the foot of the typing area and then clicking on the "Paper Clip" icon from the tools above...
    Happy to Help

    How to upload excel workbooks at this forum - http://www.excelforum.com/the-water-...his-forum.html

    "I don't get things easily, so please be precise and elaborate"

    If someone's post has helped you, thank by clicking on "Add Reputation" below the post.
    If your query is resolved please mark the thread as "Solved" from the "Thread Tools" above.

    Sourabh

  3. #3
    Registered User
    Join Date
    05-08-2015
    Location
    MI, US
    MS-Off Ver
    2013 pro
    Posts
    7

    Re: Average last 3 non-contiguous, non-zero values

    Here's the example. Each score is rounded to the nearest whole number.

    scores_example.xlsx

  4. #4
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Average last 3 non-contiguous, non-zero values

    What should be the average for week 6 in this example?

  5. #5
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Average last 3 non-contiguous, non-zero values

    If you remove the text row 12, then these ARRAY formulae will work:

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Formula: copy to clipboard
    Please Login or Register  to view this content.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  6. #6
    Registered User
    Join Date
    05-08-2015
    Location
    MI, US
    MS-Off Ver
    2013 pro
    Posts
    7

    Re: Average last 3 non-contiguous, non-zero values

    the average for week 6 should be 30

  7. #7
    Registered User
    Join Date
    05-08-2015
    Location
    MI, US
    MS-Off Ver
    2013 pro
    Posts
    7

    Re: Average last 3 non-contiguous, non-zero values

    This seems to give me an overall average...i need an average for each week...unless i'm missing something.

  8. #8
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Average last 3 non-contiguous, non-zero values

    What average do you want? You seem to be asking for two very different averages. I have given you the average for the last 3 values >0 for all the weeks.

  9. #9
    Registered User
    Join Date
    05-08-2015
    Location
    MI, US
    MS-Off Ver
    2013 pro
    Posts
    7

    Re: Average last 3 non-contiguous, non-zero values

    Sorry if i was a bit confusing in my description. I need to generate a handicap for each week that is generated off the three most recent non-zero scores. So, for instance, week 6 the handicap would use week 6, week 5, and week 1 (because weeks 2, 3, and 4 are all 0). I hope this clears it up a bit.

  10. #10
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Average last 3 non-contiguous, non-zero values

    Here is a workbook that uses 3 helper columns to calculate the 3 scores to count: (Columns H, I, J) and the average in Column K
    Enter this formula in H4 and fill across and down:
    Array formula entered with Ctrl + Shift + Enter
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Enter in K4 and fill down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    05-08-2015
    Location
    MI, US
    MS-Off Ver
    2013 pro
    Posts
    7

    Re: Average last 3 non-contiguous, non-zero values

    getting closer...the previous three scores need to be from the previous weeks...not just the previous 3 rows...so, to use my example from above, to calculate the handicap for week 6 (C30) we would average (B15(77), B4(70), B2(74)) not just the previous three non-zero rows (b15, b7, b5). sorry this is such a cluster, but this is why i came here...my feeble mind can't seem to figure out how to make this work and i really do appreciate any/all the help i can get.

  12. #12
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Average last 3 non-contiguous, non-zero values

    If you look closely, you will see that the scores are the last 3 scores and not just the last 3 rows.

  13. #13
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Average last 3 non-contiguous, non-zero values

    I see what you are doing. To calculate the 3 previous weeks without zero values, combine the two sets (front and back 9) as it doesn't make sense calculation-wise to have them separated. You can like I show in this example have the two sorted together and the calculations that I have already given you will calculate the data correctly averaging the last 3 weeks > 0

    A
    B
    C
    D
    E
    F
    G
    H
    1
    Week Score HC Course
    2
    1
    74
    30
    Front 9
    3
    2
    0
    30
    Back 9 Last Score Second Last Third Last 3 Score Ave
    4
    3
    0
    30
    Front 9
    74
    5
    4
    0
    30
    Back 9
    74
    6
    5
    70
    29
    Front 9
    70
    74
    7
    6
    77
    30
    Back 9
    77
    70
    74
    73.66667
    8
    7
    59
    26
    Front 9
    59
    77
    70
    68.66667
    9
    8
    57
    23
    Back 9
    57
    59
    77
    64.33333
    10
    9
    0
    23
    Front 9
    57
    59
    77
    64.33333
    11
    10
    0
    23
    Back 9
    57
    59
    77
    64.33333
    12
    11
    48
    15
    Front 9
    48
    57
    59
    54.66667
    13
    Back 9
    14
    Front 9
    15
    Back 9
    16
    Front 9
    17
    Back 9
    18
    Front 9
    19
    Back 9
    Attached Files Attached Files
    Last edited by newdoverman; 07-15-2015 at 06:55 PM.

  14. #14
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Average last 3 non-contiguous, non-zero values

    I have created a second worksheet and moved the calculations there. (same calculations as above) This leaves your original way of data entry intact and does the calculations on the second worksheet.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    05-08-2015
    Location
    MI, US
    MS-Off Ver
    2013 pro
    Posts
    7

    Re: Average last 3 non-contiguous, non-zero values

    Awesome! Had to massage it a bit to fit the final use case but i got it working. Thanks a ton for all the help. I really appreciate it.

  16. #16
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Average last 3 non-contiguous, non-zero values

    Thanks for the feedback.

+ 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] Using scripting dictionary to add contiguous group of items from non contiguous range
    By stnkynts in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-29-2014, 06:12 PM
  2. calculate average of non contiguous row
    By ngs007 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 01-18-2014, 12:30 PM
  3. average formula for non contiguous range and eliminate blank cells
    By kkotter in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-28-2013, 10:13 AM
  4. [SOLVED] How to delete multiple contiguous (and/or) non-contiguous rows, in an excel table
    By jimmalk in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-03-2012, 05:48 AM
  5. Average of non-contiguous column
    By MCII in forum Excel General
    Replies: 5
    Last Post: 12-24-2008, 02:30 PM
  6. Running Average with non-contiguous data
    By deedot in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-10-2008, 01:09 PM
  7. Average Non-Contiguous numbers
    By Teri in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-20-2005, 05:06 PM

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