+ Reply to Thread
Results 1 to 5 of 5

Sumproduct W/Offset to Create a Rolling Average for Filtered Cells

  1. #1
    Registered User
    Join Date
    10-02-2017
    Location
    Knoxville, TN
    MS-Off Ver
    15.12.3 (2015)
    Posts
    2

    Sumproduct W/Offset to Create a Rolling Average for Filtered Cells

    I'm trying to create a moving average of a W/L average that works with visible cells only. After a lot of research I finally found out how to create a function that works on visible cells only by using the sum product with offset function to give me a straight average.

    =(SUMPRODUCT(SUBTOTAL(3,OFFSET(Table12[Net P/L],ROW(Table12[Net P/L])-ROW(I10),0,1)),--(Table12[Net P/L]>0))/SUBTOTAL(3,(Table12[Net P/L])) )

    I now want to make that a moving average, but when I change the height in the offset reference I get either "#ref" or "#value", what do I need to change to get a moving average of a specific amount of cells. For this example let's say that # of cells is 10. So I want the average of the last 10 visible cells only. Is it as simple as just changing a number above? Or is it a completely different setup.


    Also I'm new to Excel, I just started teaching myself the ins & outs a couple weeks ago to make my life easier, so please do not expect me to know certain things.

    If more information is needed to provide me with the solution, please let me know.
    Last edited by gtnewberry; 10-04-2017 at 07:30 AM.

  2. #2
    Forum Expert
    Join Date
    06-26-2010
    Location
    Austin, TX
    MS-Off Ver
    Excel 2010
    Posts
    1,673

    Re: Sumproduct W/Offset to Create a Rolling Average for Filtered Cells

    Interesting issue. Ignoring hidden cells has some tricks (as you have found) but there may be a breaking point with what you can do.

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. 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.
    Pauley
    --------
    If I helped with your issue, I'd appreciate a rep bump (hit the '*' icon to the bottom left of this post).

  3. #3
    Registered User
    Join Date
    10-02-2017
    Location
    Knoxville, TN
    MS-Off Ver
    15.12.3 (2015)
    Posts
    2

    Re: Sumproduct W/Offset to Create a Rolling Average for Filtered Cells

    I created a sample worksheet, deleting all of the actual data & created an example sheet by itself, that should do.

    As you can see everything on the sheet is using a function that makes it calculate visible cells only. And I'm not going to lie, I'm kind of proud of myself just being introduced to Excel 2 weeks ago to come up with & learn those functions, but this Moving Average is stumping me. I've tried everything...even trial & error & can't come up with anything. I need it to use the function, or one that produces the same outcome, as the one in the "Winning %" because it is calculating based on rules.

    If this is not possible, then thank you for trying. I can just set up a helper cell in another sheet that calculates the moving average using my weekly data, I've already found out that it works that way, because I'm not having to use any "ifs" in it, it is just calculating the average of cells that already have the average in them based upon the requirements. It's just far from exact.

    For the sake of this example let's say that the offset that I want is 10 cells again.

    Again, this is the original function:

    =(SUMPRODUCT(SUBTOTAL(3,OFFSET(Table12[Net P/L],ROW(Table12[Net P/L])-ROW(H10),0,1)),--(Table12[Net P/L]>0))/SUBTOTAL(3,(Table12[Net P/L])) )

    Thank You!!
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    08-31-2017
    Location
    Miami
    MS-Off Ver
    2016
    Posts
    1

    Re: Sumproduct W/Offset to Create a Rolling Average for Filtered Cells

    I'm also trying to solve the same issue: an AverageIf based on text criteria in Column V to average $'s in Column D; that only averages the visible cells that meet the text criteria. Looking forward to seeing if this thread helps. TIA.

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Sumproduct W/Offset to Create a Rolling Average for Filtered Cells

    Quote Originally Posted by gtnewberry View Post
    .....So I want the average of the last 10 visible cells only...... Is it as simple as just changing a number above?
    No, the OFFSET needs to remain the same so that you can evaluate each cell separately.

    It would probably be a lot easier with a helper column (to indicate for each row whether it's visible or not).

    Failing that you can use this generic formula - assuming Range is a single column of data

    =AVERAGE(IF(SUBTOTAL(2,OFFSET(Range,ROW(Range)-MIN(ROW(Range)),0,1)),IF(ROW(Range)>=LARGE(IF(SUBTOTAL(2,OFFSET(Range,ROW(Range)-MIN(ROW(Range)),0,1)),ROW(Range)),10),Range)))
    Audere est facere

+ 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. Rolling average using offset that ignores blanks
    By jd33a in forum Excel General
    Replies: 1
    Last Post: 09-07-2017, 05:14 PM
  2. How to create a rolling average conditional formula
    By MHayward in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-14-2014, 06:33 AM
  3. Create a rolling 30 day average based on dates in heading.
    By jumper121187 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-16-2014, 10:16 PM
  4. How to create a rolling 6 month average?
    By anley in forum Excel General
    Replies: 4
    Last Post: 12-08-2010, 11:34 PM
  5. Rolling Average:use INDEX and OFFSET
    By SKAh in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-18-2007, 09:41 PM
  6. [SOLVED] How do I create a rolling average chart, adding most recent data?
    By Doug@NxEdge in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 11-04-2005, 10:30 PM
  7. [SOLVED] How can I create a rolling average between 2 values?
    By tomcat in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-28-2005, 11:06 AM

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