Calculating the overlap time between observations

ETSHA

New Member
Joined
Nov 2, 2013
Messages
8
Hi all,
I'm working on a large dataset (85 K obs), for each observation I have a start date, start time, end date, end time, a field defining whether the observation is a commercial or a show and channel.
I want to calculate the amount of overlap time between observations such that they are both commercials and are different channels. Meaning, if I have three channels, then for a relevant observation (commercial) I want to know the amount of overlap time with each of the two other channels separately.
Any ideas on ow to go about doing this?

ET
 
Please be patient. Bumping so frequently makes you appear demanding. Your question isn't trivial so a solution may take some time, if one exists at all.
 
Upvote 0

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Formula in J2 copied down and across. I formatted the cells as hh:mm:ss;;; to suppress the display of zeroes. The formula is complex, so I don't know if it will work for 85,000 rows.


Excel 2010
ABCDEFGHIJKL
1IndexShow/CommChannelWeekdayS_DateS_TimeE_DateE_TimeDurationOverlap with Channel 1Overlap with Channel 2Overlap with Channel 3
253027Commercial1226/04/200421:07:5526/04/200421:10:360002:41 
353029Commercial1226/04/200421:11:5826/04/200421:12:280000:30
453031Commercial1226/04/200421:25:1226/04/200421:26:400001:28
553034Commercial2226/04/200419:29:4126/04/200419:29:480000:07
653038Commercial2226/04/200421:13:5226/04/200421:17:050003:1300:00:15
753039Commercial2226/04/200421:20:3426/04/200421:20:420000:08
853041Commercial2226/04/200421:32:2926/04/200421:41:400009:1100:02:15
953042Commercial2226/04/200421:54:4826/04/200422:03:060008:1800:01:50
1053043Commercial2226/04/200422:22:2126/04/200422:30:590008:38
1153044Commercial2226/04/200422:44:1326/04/200422:52:240008:11
1253045Commercial2226/04/200422:59:4126/04/200423:01:220001:41
1353046Commercial3226/04/200419:04:1226/04/200419:04:260000:14
1453048Commercial3226/04/200419:29:2326/04/200419:29:400000:17
1553052Commercial3226/04/200421:15:2126/04/200421:15:360000:1500:00:15
1653054Commercial3226/04/200421:29:2726/04/200421:34:440005:1700:02:15
1753055Commercial3226/04/200421:49:2326/04/200421:54:320005:09
1853056Commercial3226/04/200422:01:1626/04/200422:07:540006:3800:01:50
1953058Commercial3226/04/200422:32:1126/04/200422:38:420006:31
Sheet1
Cell Formulas
RangeFormula
J2{=IF($C2=(RIGHT(J$1,1)+0),"",SUM(IF($C$2:$C$19=(RIGHT(J$1,1)+0),IF((($E$2:$E$19+$F$2:$F$19)<=($E2+$F2))*(($G$2:$G$19+$H$2:$H$19)>=($E2+$F2)),IF(($G$2:$G$19+$H$2:$H$19)>=($G2+$H2),($G2+$H2),($G$2:$G$19+$H$2:$H$19))-IF(($E$2:$E$19+$F$2:$F$19)<=($E2+$F2),($E2+$F2),($E$2:$E$19+$F$2:$F$19)),IF((($E$2:$E$19+$F$2:$F$19)>=($E2+$F2))*(($E$2:$E$19+$F$2:$F$19)<=($G2+$H2)),IF(($G$2:$G$19+$H$2:$H$19)>=($G2+$H2),($G2+$H2),($G$2:$G$19+$H$2:$H$19))-IF(($E$2:$E$19+$F$2:$F$19)<=($E2+$F2),($E2+$F2),($E$2:$E$19+$F$2:$F$19)))))))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
  • Like
Reactions: shg
Upvote 0
That is impressive, Andrew!
 
Upvote 0
I think you can simplify Andrew's formula a little - this version in J2 should give the same results:

=IF($C2=RIGHT(J$1)+0,"",SUM(IF(($C$2:$C$19=RIGHT(J$1)+0)*($E$2:$E$19+$F$2:$F$19<$G2+$H2)*($G$2:$G$19+$H$2:$H$19>$E2+$F2),IF($G$2:$G$19+$H$2:$H$19< $G2+$H2,$G$2:$G$19+$H$2:$H$19,$G2+$H2)-IF($E$2:$E$19+$F$2:$F$19 >$E2+$F2,$E$2:$E$19+$F$2:$F$19,$E2+$F2))))

confirmed with CTRL+SHIFT+ENTER
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,482
Messages
6,125,058
Members
449,206
Latest member
Healthydogs

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