Formula to determine the Max

Mbishop

New Member
Joined
Feb 24, 2016
Messages
9
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
I'm trying to figure out if there is a more efficient way of calculating the max number of trailers in an area based on arrival and departure. Example below is how i'm currently determining.

ABCDED
1SupplierArrival Date & TimeDeparture Date & TimeTrailer4/19/18 01:00:004/19/18 02:00:00
2ASD4/20/18 0:01:124/20/18 16:34:33A23400
3ASD4/20/18 11:00:524/20/18 16:00:00A23500
4BFB4/19/18 01:05:344/22/18 03:05:56B54501
5CCC4/19/18 05:06:354/20/18 03:20:36C55500
6BFB4/18/18 00:30:154/22/18 03:56:45B54611
7MAX#TOTAL12

<tbody>
</tbody>

In example above I have data of when trailer arrives and departs. I'm using rows E through AA... were I have date with time in hour increments and using using an If formula in cells below those rows =If(E$1>=$B2,if(E$2<=$C2,1,0),0) then summing each column to determine the max peak of trailers in area at that time. Then I have =max(E7:AA...7) were it returns the max trailers.

I would really like to get away from using hourly increments, as Max is not truly accurate, but if I use minutes spread sheet would be more massive than it already is. If possible I would like to input a formula that determines the max so I can get away from adding in the incremental times.

Any considerations and help will be much appreciated.

Thanks
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Perhaps:

D2: =SUMPRODUCT(--(B$2:B$7<=B2),--(C$2:C$7>B2))
E2: =IF(D2=MyMax,B2,"")
F2: =IF(D2=MyMax,INDEX(C$2:C$7,MATCH(MIN(IF(C$2:C$7>B2,C$2:C$7-B2)),C$2:C$7-B2,)),"") array-entered
MyMax: =D9 =MAX(D2:D7)

Incidentally, I used Sumproduct rather than Countif because Countif seems to be subject to Excel precision errors, e.g. compare:

=COUNTIF(C2:C7,">"&C4) =4, wrong!
=SUMPRODUCT(--(C2:C7>C4)) = 3, correct


Book1
ABCDEF
1SupplierArriveDepartArrive CountStartEnd
2A20 Apr 18 2:00:0020 Apr 18 16:00:00420 Apr 18 2:0020 Apr 18 16:00
3B18 Apr 18 0:30:0018 Apr 18 15:00:001
4C19 Apr 18 1:05:0021 Apr 18 3:05:561
5D19 Apr 18 2:00:0021 Apr 18 9:00:002
6E19 Apr 18 5:06:0022 Apr 18 3:20:003
7F21 Apr 18 1:30:0021 Apr 18 16:00:00421 Apr 18 1:3021 Apr 18 3:05
8
9MAX4
Sheet1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,305
Members
449,079
Latest member
juggernaut24

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