+ Reply to Thread
Results 1 to 9 of 9

Average if time ranges overlap

  1. #1
    Registered User
    Join Date
    11-24-2014
    Location
    toronto
    MS-Off Ver
    2013
    Posts
    5

    Average if time ranges overlap

    I'm at a loss. I've searched high and low for a solution.

    HTML Code: 
    I'm try to find out which units were active during the intervals set in d (d2:d3, d3:d4, etc) and then average out the size of those units in e.

    I can identify which ones are active with a variation of the following:

    =if(or(and(C1:c6>=D1, D2< B1:B6), "overlap", "no overlap")

    But I don't know how to use this to find the average of the units that match the criteria. I was something of something like this:

    =if(or(and(b1:b6>=d2, b1:b6<=d2),and(d1>=b1:b6,d1<=c1:c6),average(a1:a6),0)

    I know this is wrong. Any help would be appreciated. I have other conditions (5-6, but none with "and" or "or") to meet asides from this time range overlap criteria, but I think I can figure out how to implement these once I get pass this hurdle. Anything helps at this point.
    Last edited by fitzxlr8s; 11-24-2014 at 12:39 PM.

  2. #2
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Average if time ranges overlap

    As you can see... its hard to determine the stracture..

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and use the paperclip icon to open the upload window.

    View Pic
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  3. #3
    Registered User
    Join Date
    11-24-2014
    Location
    toronto
    MS-Off Ver
    2013
    Posts
    5

    Re: Average if time ranges overlap

    I saw that right away.I fixed the outline in the first post.
    Attached Files Attached Files

  4. #4
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Average if time ranges overlap

    I am lil bit confused.. answer is also not matching with you..

    still can you please check this one..

    In P8 use formula as
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    you can drag for other dates..

  5. #5
    Registered User
    Join Date
    11-24-2014
    Location
    toronto
    MS-Off Ver
    2013
    Posts
    5

    Re: Average if time ranges overlap

    Unfortunately, this function only accounts for part of the units. there are more time ranges that overlap. +2 for example overlaps but it isn't counted. 2/1/14 : 5:5/2/14 overlaps with 1/1/14 : 4/1/14. That's why the "and" & "or" are so important.

  6. #6
    Registered User
    Join Date
    11-24-2014
    Location
    toronto
    MS-Off Ver
    2013
    Posts
    5

    Re: Average if time ranges overlap

    Quote Originally Posted by Debraj Roy View Post
    I am lil bit confused.. answer is also not matching with you..

    still can you please check this one..

    In P8 use formula as
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    you can drag for other dates..
    Here's how i manually calculated the E values

    E1: units A1, A2, A3, A4 all have time ranges that overlap D1:D2

    400 + 500 +400 +1200 = 2500
    2500 / 4 units = 625

    E2: units A1, A2, A3, A4, A5, A6 all overlap D2:D3
    4100 / 6 units = 683 (mistake in my original data. can Correct in edit, sorry)

    E3: Units A3, A4, A5 overlap D3:D4
    3100 / 3 units = 1033

    E4: Units A5 is the only unit to overlap D4:D5
    1500 / 1 unit = 1500

    E5: Not units overlap D5:D6

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Average if time ranges overlap

    Maybe ...

    Row\Col
    A
    B
    C
    D
    E
    F
    1
    Size
    start
    end
    Intervals
    Avg Active
    2
    400
    01/01/2014
    04/01/2014
    01/01/2014
    625.0
    E2: =IFERROR(AVERAGEIFS($A$2:$A$7, $B$2:$B$7, "<=" & D3, $C$2:$C$7, ">=" & D2), 0)
    3
    500
    02/01/2014
    05/02/2014
    04/01/2014
    683.3
    4
    400
    03/01/2014
    08/01/2014
    07/01/2014
    1033.3
    5
    1200
    04/01/2014
    07/01/2014
    10/01/2014
    1500.0
    6
    1500
    05/01/2014
    11/01/2014
    01/01/2015
    0.0
    7
    100
    06/01/2014
    06/02/2014
    04/01/2015
    Entia non sunt multiplicanda sine necessitate

  8. #8
    Registered User
    Join Date
    11-24-2014
    Location
    toronto
    MS-Off Ver
    2013
    Posts
    5

    Re: Average if time ranges overlap

    Quote Originally Posted by shg View Post
    Maybe ...

    Row\Col
    A
    B
    C
    D
    E
    F
    1
    Size
    start
    end
    Intervals
    Avg Active
    2
    400
    01/01/2014
    04/01/2014
    01/01/2014
    625.0
    E2: =IFERROR(AVERAGEIFS($A$2:$A$7, $B$2:$B$7, "<=" & D3, $C$2:$C$7, ">=" & D2), 0)
    3
    500
    02/01/2014
    05/02/2014
    04/01/2014
    683.3
    4
    400
    03/01/2014
    08/01/2014
    07/01/2014
    1033.3
    5
    1200
    04/01/2014
    07/01/2014
    10/01/2014
    1500.0
    6
    1500
    05/01/2014
    11/01/2014
    01/01/2015
    0.0
    7
    100
    06/01/2014
    06/02/2014
    04/01/2015
    marry me, please

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Average if time ranges overlap

    You're welcome.

+ 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] Overlap between two time ranges
    By LondonJames in forum Excel General
    Replies: 11
    Last Post: 07-12-2019, 02:18 AM
  2. [SOLVED] determine total overlap time when there are gaps in overlap (4 date ranges)
    By miriambender in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-12-2014, 11:58 PM
  3. Calculate total hours if time ranges overlap
    By jl_stewart in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 12-03-2013, 10:21 PM
  4. Replies: 5
    Last Post: 07-10-2012, 03:03 PM
  5. Average over different time ranges
    By nasalcherry in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2008, 04:10 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