Counting the number of discharges

Hi

I need to count the number of discharges based on discharge start and discharge end date and times - see test data.

TEST DATA.xlsx

However, the counting rule is not just a straight count of the number of rows. I am required to count the number of spills based on the 12/24 counting method, the rules of which are described below:

  1. Start counting when the first discharge occurs.

  2. Any discharge (or discharges) in the first 12-hour block are counted as one spill.

  3. Any discharge (or discharges) in the next, and subsequent 24-hour blocks, are each counted as one additional spill per block.

  4. Continue counting until there’s a 24-hour block with no discharge.

For the next discharge after the 24-hour block with no discharge, you begin again with the 12-hour and 24-hour block spill counting sequence.

For example, the following discharges would give a count of 3 (as the first 2 discharges are within 12 hours of each other and the next two are within the next 24 hour block. There is a gap of more than 24 hours between the 16/10/24 and 06/12/24 discharges so the spill count would start again for the 06/12/24 discharge)

16/10/2024 04:44:59

16/10/2024 15:14:59

16/10/2024 21:44:59

16/10/2024 23:44:59

06/12/2024 21:14:59

For reference, a manual calculation of all the discharges in the test file give a 12/24 spill count of 17.

I am struggling to create a workflow to calculate this so any help would be greatly appreciated.

Thanks