Calculating the number of simultaneous incidents

Gsc265

New Member
Joined
May 25, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
Hi everyone,

I am looking to calculate from my dummy dataset over which hours of the day vehicles are deployed (between alert time and available time).

The dataset has 4 columns;
Incident number (column A) general format
Vehicle id (Column B) general format
Alert time (Column C) datetime (dd/mm/yyyy hh:mm:ss)
Available time (Column D) (dd/mm/yyyy hh:mm:ss)

I had successfully tried the below formula from a thread on another site; however I forgot to save it and i havent been able to get it to work since.

=MMULT(RANDARRAY(1,COUNT(Alert time column range),1,1,TRUE),BITAND({0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}<=Alert time column range,{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}>=Alert time column range))

Link to original question where above formula came from - Find number of simultaneous activites from a list of times

The above formula produced a output of columns from 0 - 23 and showed a value of 1 if the alert time - available time fell within the hour number. I have replicated this manually on the image.

For example, the 1st row of data shows the vehicle times between 01:31:17 - 01:52:56. As this time range falls within hour 1, the 1 column has a value of 1.
In the 2nd row of data however, the vehicle time spans over 3 hour periods (9-10, 10-11 and 11-12) so columns 9, 10 and 11 all receive a value of 1.

I hope this makes sense and any help would be greatly appreciated.
 

Attachments

  • Screenshot.png
    Screenshot.png
    35.8 KB · Views: 18

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
*typo above - formula should have said =MMULT(RANDARRAY(1,COUNT(Alert time column range),1,1,TRUE),BITAND({0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}<=Available time column range,{0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23}>=Alert time column range))
 
Upvote 0
Hi & welcome to MrExcel.
How about
Fluff.xlsm
CDGHIJKLMNOPQRSTUVWXYZAAABACAD
101234567891011121314151617181920212223
211/03/2023 01:3111/03/2023 01:52010000000000000000000000
311/03/2023 09:5011/03/2023 11:47000000000111000000000000
Master
Cell Formulas
RangeFormula
G1:AD1G1=SEQUENCE(,24,0)
G2:AD3G2=IF((HOUR(C2:C3)<=G1:AD1)*(HOUR(D2:D3)>=G1:AD1),1,0)
Dynamic array formulas.
 
Upvote 0
Solution
Hi & welcome to MrExcel.
How about
Fluff.xlsm
CDGHIJKLMNOPQRSTUVWXYZAAABACAD
101234567891011121314151617181920212223
211/03/2023 01:3111/03/2023 01:52010000000000000000000000
311/03/2023 09:5011/03/2023 11:47000000000111000000000000
Master
Cell Formulas
RangeFormula
G1:AD1G1=SEQUENCE(,24,0)
G2:AD3G2=IF((HOUR(C2:C3)<=G1:AD1)*(HOUR(D2:D3)>=G1:AD1),1,0)
Dynamic array formulas.
Hi Fluff,
Thank you for the reply and very sorry about my delayed thanks.
I have tried the formula and it works on incidents where the alert time and available time are on the same day. However when the available time is on a future day, the row shows 0 for all values.


Example data.
Alert time - 01/04/2018 23:21:24
Available time - 02/04/2018 00:57:55

Any help again would be greatly appreciated.
 
Upvote 0
That is exactly what the formula you posted would do.
 
Upvote 0
This will get you part way.
Excel Formula:
=IF((HOUR(C2:C3)<=G1:AD1)*(IF(INT(D2:D3)<=INT(C2:C3),HOUR(D2:D3),24)>=G1:AD1),1,0)
 
Upvote 0
How about
Excel Formula:
=IF(((HOUR(C2:C3)<=G1:AD1)*(IF(INT(C2:C3)<INT(D2:D3),24,HOUR(D2:D3))>=G1:AD1))+(IF(INT(C2:C3)<INT(D2:D3),HOUR(D2:D3)>=G1:AD1,)),1,0)
 
Upvote 0
How about
Excel Formula:
=IF(((HOUR(C2:C3)<=G1:AD1)*(IF(INT(C2:C3)<INT(D2:D3),24,HOUR(D2:D3))>=G1:AD1))+(IF(INT(C2:C3)<INT(D2:D3),HOUR(D2:D3)>=G1:AD1,)),1,0)
HI Fluff,

That works great. It is putting the hours captured in the morning cells from the day after into the row before, which will do for what I require.

Many thanks,
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

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