+ Reply to Thread
Results 1 to 4 of 4

Average of range of dates with hidden / filtered rows

  1. #1
    Registered User
    Join Date
    11-21-2010
    Location
    Zurich, Switzerland
    MS-Off Ver
    Excel 2003
    Posts
    2

    Average of range of dates with hidden / filtered rows

    Hi Excel Experts,

    I need urgent help with the following problem:

    I have three rows (each of which stands for one document that undergoes a particular review cycle) Per row (ie document), I know Date B and Date A (with Date B being later in time than Date A). Now I want to calculate the average duration (in days) across all rows, i.e. I need to look at what is the duration in days per row; then sum this up; then divide by the count of rows.

    So far, I have identified following solutions to calculate the average:
    =SUM(($J$5:$J$8)-($D$5:$D$8))/COUNT($D$5:$D$8)
    and then enter as an array.
    [J5:J8 and D5:D8 are the ranges in which Dates B respectively A can be found]
    This formula works out well (albeit it may not be very elegant).

    However, there is one complication: I have hidden and filtered some rows. If I use the formula above, this shows all rows, not just the filtered ones and no longer gives the correct average.

    I have tried to adapt the above formula in SUBTOTAL, i.e.
    =SUBTOTAL(101, (($J$5:$J$8)-($D$5:$D$8))), entering as array
    or =SUBTOTAL (101, SUM(($J$5:$J$8)-($D$5:$D$8)))
    and also =SUBTOTAL(109,(($J$5:$J$8)-($D$5:$D$8)))/SUBTOTAL(102,($D$5:$D$8)), entering as array

    but none of it works.

    Can anybody help?

    Thank you!!

  2. #2
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Average of range of dates with hidden / filtered rows

    post a sample workbook but i think
    =(SUBTOTAL(109,J5:J8)-SUBTOTAL(109,D5:D8))/SUBTOTAL(102,D5:D8)
    should do it
    you dont need to subtract the corresponding cells of each range just the total the result will be the same
    Last edited by martindwilson; 11-21-2010 at 09:04 AM.
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  3. #3
    Forum Contributor
    Join Date
    01-28-2010
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2003
    Posts
    157

    Re: Average of range of dates with hidden / filtered rows

    Could you use a helper column with this formula in row 5 filled down to row 8..
    =J5-D5
    Then this formula for the average, assuming column K has the above formula...
    =SUBTOTAL(109,K5:K8)/SUBTOTAL(102,K5:K8)
    Then the average is based on the visible rows only.

  4. #4
    Registered User
    Join Date
    11-21-2010
    Location
    Zurich, Switzerland
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Average of range of dates with hidden / filtered rows

    Dear Martin, dear beaunydal,

    thanks a lot for your quick replies! Actually both solutions work perfectly, I will go with Martin's one as it does not need a helper column there.

    Thank you so much again!

+ 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