+ Reply to Thread
Results 1 to 10 of 10

Running average problem

  1. #1
    Registered User
    Join Date
    04-24-2014
    Location
    Lutz, FL
    MS-Off Ver
    Excel 2010
    Posts
    8

    Running average problem

    ____A______B_____C________D
    1__4.305____1___4.305____4.305
    2__4.305____1___4.305____4.305
    3__4.305____0___
    5__3.95_____0___
    6__4.005____1___4.005____4.0525
    7__4.005____1___4.005____4.005


    I have data as such in columns A,B, and C; actually a small sample of several thousand points. Anyway, for column D, here is what I would like returned:

    Anywhere there is a 1 value in B (example: row 6), I want D to look back at the previous rows for 0 values in column B until it hits a 1 (rows 3, 4, and 5 all contain 0s, but B2 contains a 1), then take an average of corresponding values in A. In the above sample D6 equals the average of A3 trhu A6 (D6=[A3+A4+A5+A6]/4) or (4.0525=[4.305+3.95+3.95+4.005]/4). Notice D7=A7 because B6=1. So D7 looks back at B6, sees that B6=1, therefore returns A7. Similarly D2=A2 because B1=1.


    A problem with my data set is that there may be a bunch of 0s consecutively in column B, and sometimes there are a bunch of 1 consecutively. This seems to me like it would take multiple steps to solve. I am not familiar with macros, but if that's what it takes I'd be willing to try to learn.

    I hope someone understands my explanation and can give me an answer! Thanks in advance.
    Last edited by ctrap33; 04-24-2014 at 12:44 PM. Reason: formatting

  2. #2
    Registered User
    Join Date
    04-24-2014
    Location
    Lutz, FL
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Running average problem

    __________________bump.

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Running average problem

    You get better help if you add an excel file with your data (without confidential information)
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Running average problem

    ctrap, forum rules require you to wait at least 24 hours befor bumping. Also, some members only view threads with 0 responses, this thread now had 2
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    04-24-2014
    Location
    Lutz, FL
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Running average problem

    I looked for a way to do that. Didn't think you could

  6. #6
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Running average problem

    @ctrap33

    Please Login or Register  to view this content.
    Please reply to whom you are replying.

  7. #7
    Registered User
    Join Date
    04-24-2014
    Location
    Lutz, FL
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Running average problem

    I have linked the complete workbook [Sheet1] with expected answers highlighted in orange (column D) for the first 10 rows.

    Thanks
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    04-24-2014
    Location
    Lutz, FL
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Running average problem

    Quote Originally Posted by FDibbins View Post
    ctrap, forum rules require you to wait at least 24 hours befor bumping. Also, some members only view threads with 0 responses, this thread now had 2
    So, should I scrap this post and start a new one now that I figured out how to link a workbook?

  9. #9
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,943

    Re: Running average problem

    Insert a blank line above your data, and then in cell D2, array enter the formula

    =IF(C2=0,"",IFERROR(AVERAGE(IF(ROW($B$2:B2)>(MAX(IF($C1:C$2=1,ROW($C1:C$2)))),$B$2:B2)),B2))

    and copy down to match your data set.

    Here's your modified file.

    With formula.xlsx
    Last edited by Bernie Deitrick; 04-24-2014 at 01:10 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

  10. #10
    Registered User
    Join Date
    04-24-2014
    Location
    Lutz, FL
    MS-Off Ver
    Excel 2010
    Posts
    8

    Re: Running average problem

    Quote Originally Posted by Bernie Deitrick View Post
    Insert a blank line above your data, and then in cell D2, array enter the formula

    =IF(C2=0,"",IFERROR(AVERAGE(IF(ROW($B$2:B2)>(MAX(IF($C1:C$2=1,ROW($C1:C$2)))),$B$2:B2)),B2))

    and copy down to match your data set.

    Here's your modified file.

    Attachment 313897

    Awesome. Exactly what I was looking for. Sorry for not complying with forum rules. Consider this topic solved.

+ 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] Average Hours Per Day - Running Total Average
    By ABAUS in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 03-06-2014, 03:42 PM
  2. Replies: 1
    Last Post: 05-13-2009, 02:40 AM
  3. Running average
    By indira in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-05-2009, 06:28 PM
  4. Average - How to create a running Average
    By Mihir72 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-27-2008, 11:12 AM
  5. Running Average
    By lsmft in forum Excel General
    Replies: 5
    Last Post: 03-28-2006, 05:44 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