I am trying to get my head around an MS excel formula for a scenario I have.
I am recording discharges over various sample periods. These sample periods will last anywhere from 24 hrs to 1 week. The sample period will be recorded with a start and end time (dd/mm/yy hh:mm).
I want to be able to report the sum discharge total for all sample periods for each calendar month, but ensuring that any sample periods that span two months (i.e. 27/02/24 14:00 >> 05/03/24 14:00) have the total discharge value proportionately distributed between each month total. I acknowledge that this assumes that the discharges are constant rate, which they are for this task. For the time range in brackets, this would be ~34% of the sample period total allocated to Feb-24 as an example.
If anyone can suggest a formula for F3 to satisfy what I've described above, that would be fantastic.
Screenshot attached.
I haven't tried anything so far, because I don't really know where to start with this. I've tried in vain to find a solution online.
You can use the overlap formula
to give you the number of days and hours which fall within the current month. When applied as an array formula in this case it would give you
Note the use of eomonth(E2,0)+1 which takes you to midnight on the last day of the current month.