averageifs of value if 2 time range overlap

fitzxlr8s

New Member
Joined
Nov 23, 2014
Messages
4
I'm at a loss. I've searched high and low for a solution.

A2:A5 size unit
B2:B5 time range beginning
C2:C5 time range end

$d$2 : Date1
$d$3 : Date2

I'm trying to find the average size of units that were active during D2:D3

I can identify if time ranges intersect with:

=if(or( c2:c5 <d2,d3<b2:b5), "overlap", "no overlap")<d2.d3<b2:b5), "overlap",="" "no="" overlap")<d2,d3<b2:b5),="" no="" overlap")


But I don't know how to use this to find the average of the units.

=if(or(and(b2:b5>=d2, b2:b5<=d3),and(d2>=b2:b5,d2<=c2:c5),average(a2:a5),0)

I know this is wrong. Any help would be appreciated</d2.d3<b2:b5),>
 
Last edited:

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
for some reason my first formula isn't showing up in my post.

=if(or(and(C2:c5>=D2,D3< B2:B5), "overlap", "no overlap")
 
Last edited by a moderator:
Upvote 0
Welcome to the MrExcel board!

If you have a formula with a "<" symbol followed by a letter, the forum software thinks it it is HTML code and the result is what happened to you. If that happens, just edit your post and put a space between those two characters, as I have done for you in your second post.

Now, in relation to your question, could we see some sample data and expected result(s) with an explanation related directly to that sample?
 
Upvote 0
Thank you Peter. Here's a quick sample:

[TABLE="width: 669"]
<colgroup><col><col><col><col><col span="2"><col><col></colgroup><tbody>[TR]
[TD][/TD]
[TD]a[/TD]
[TD]b[/TD]
[TD]c [/TD]
[TD][/TD]
[TD][/TD]
[TD]d[/TD]
[TD]e[/TD]
[/TR]
[TR]
[TD][/TD]
[TD]Size[/TD]
[TD]contract_start[/TD]
[TD]contract_End[/TD]
[TD][/TD]
[TD][/TD]
[TD]Intervals[/TD]
[TD]Avg_Size_ Active[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]400[/TD]
[TD]1/1/2014[/TD]
[TD]4/1/2014[/TD]
[TD][/TD]
[TD][/TD]
[TD]1/1/2014[/TD]
[TD]625.00[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]500[/TD]
[TD]2/1/2014[/TD]
[TD]5/2/2014[/TD]
[TD][/TD]
[TD][/TD]
[TD]4/1/2014[/TD]
[TD]740.00[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]400[/TD]
[TD]3/1/2014[/TD]
[TD]8/1/2014[/TD]
[TD][/TD]
[TD][/TD]
[TD]7/1/2014[/TD]
[TD]1033.33[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]1200[/TD]
[TD]4/1/2014[/TD]
[TD]7/1/2014[/TD]
[TD][/TD]
[TD][/TD]
[TD]10/1/2014[/TD]
[TD]1500.00[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]1500[/TD]
[TD]5/1/2014[/TD]
[TD]11/1/2014[/TD]
[TD][/TD]
[TD][/TD]
[TD]1/1/2015[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]100[/TD]
[TD]6/1/2014[/TD]
[TD]6/2/2014[/TD]
[TD][/TD]
[TD][/TD]
[TD]4/1/2015[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 605"]
<colgroup><col><col><col><col span="2"><col><col></colgroup><tbody></tbody>[/TABLE]


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.
 
Upvote 0
Could you ..
a) confirm whether your dates are d/mm/yy or m/dd/yy?
b) explain how you manually calculated those results?

a) my dates are mm/dd/yy
b) Here's how I manually calculated the "E" column

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
 
Upvote 0
Try this. To avoid the error values you might want to wrap the formula in an IFERROR() function.

Excel Workbook
ABCDE
1Sizecontract_startcontract_EndIntervalsAvg_Size_ Active
24001/01/141/04/141/01/14625
35001/02/142/05/141/04/14683.3333333
44001/03/141/08/141/07/141033.333333
512001/04/141/07/141/10/141500
615001/05/141/11/141/01/15#DIV/0!
71001/06/142/06/141/04/15#DIV/0!
Average
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top