SOLVED

Overlapping Time Data

Copper Contributor

Hello,

 

I am trying to figure out how to calculate uptime and downtime from a dataset that I have. The data has a category, start time, and finish time. Some of the records overlap in time, but I only want to count one category at any given time. 

 

Here is the logic I want to implement:

 

1) Jobs count towards uptime

2) If there is downtime during a period where a job is ongoing, subtract that downtime duration from the job duration

3) If there is prep ongoing during another activity, do not count it. However, for the duration that the prep does not overlap with another activity, it should be counted as downtime.

4) If there is no data between the hours of 6:00 and 22:30, count it as category "no data" 

 

Here is a sample of the data:

 

Job9/28/2023 6:389/28/2023 7:10
Prep9/28/2023 7:109/28/2023 9:30
Job9/28/2023 9:469/28/2023 9:57
Exchange9/28/2023 9:579/28/2023 10:22
Job9/28/2023 10:229/28/2023 12:09
Prep9/28/2023 12:009/28/2023 12:49
Exchange9/28/2023 12:499/28/2023 12:49
Job9/28/2023 12:499/28/2023 13:26
Prep9/28/2023 13:009/28/2023 14:25
Job9/28/2023 14:259/28/2023 15:18
Prep9/28/2023 15:199/28/2023 15:44
Exchange9/28/2023 15:459/28/2023 16:57
Job9/28/2023 16:579/28/2023 16:58
Job9/28/2023 16:589/28/2023 21:19
Downtime9/29/2023 6:429/29/2023 7:52
Prep9/29/2023 7:539/29/2023 8:19
Exchange9/29/2023 8:199/29/2023 8:19
Job9/29/2023 8:209/29/2023 13:47
Downtime9/29/2023 9:009/29/2023 9:30

 

Additionally, I would like to be able to summarize the data and view by daily, weekly, monthly.  Can this be accomplished?

4 Replies

@ExcelNoob625 

To calculate uptime and downtime from your dataset and implement the described logic, you can use Excel formulas and possibly pivot tables for summarizing the data by daily, weekly, and monthly views. Here is a step-by-step guide to achieving this:

Step 1: Data Preparation Ensure your data is organized in columns with headings "Category," "Start Time," and "Finish Time." Make sure the date and time values are recognized as date/time data types in Excel.

Step 2: Calculate Uptime and Downtime You can create additional columns to calculate uptime and downtime based on your logic. Here is a general structure for the formulas you can use:

  • Column 😧 Uptime (in minutes)

=IF(A2="Job", IF(C2-B2>0, (C2-B2)*1440, 0), "")

  • Column E: Downtime (in minutes)

=IF(A2="Downtime", IF(C2-B2>0, (C2-B2)*1440, 0), "")

  • Column F: No Data (in minutes)

=IF(AND(TEXT(B2,"hh:mm")<="06:00", TEXT(C2,"hh:mm")>="22:30"), (C2-B2)*1440, "")

Copy these formulas down to apply to your entire dataset.

Step 3: Handle Overlapping Time To handle overlapping time, you can use a more advanced formula or VBA macro, which would require a more detailed understanding of your specific data and requirements. It is essential to consider the sequence of activities and how they overlap.

Step 4: Summarize Data To summarize the data by daily, weekly, and monthly views, you can use Excel pivot tables:

  1. Select your data range, including the new columns for uptime, downtime, and no data.
  2. Go to the "Insert" tab and click "PivotTable."
  3. In the PivotTable Field List, drag the "Category" field to the "Rows" area, "Uptime," "Downtime," and "No Data" fields to the "Values" area.
  4. In the PivotTable, right-click on the "Dates" field (your timestamp column) and group it by the desired time interval (daily, weekly, or monthly).
  5. Customize your PivotTable to display the data as needed.

This PivotTable will allow you to view uptime, downtime, and no data summaries by the selected time intervals.

Please note that handling overlapping time may require more complex Excel formulas or VBA coding, depending on the specific scenarios in your dataset. You may need to adjust the provided formulas to match your exact requirements. The text and steps were edited with the help of AI.

 

My answers are voluntary and without guarantee!

 

Hope this will help you.

Was the answer useful? Mark them as helpful and like it!

This will help all forum participants.

@ExcelNoob625 

Tried to do that with Power Query

image.png

But that's only mock-up. Queries could be and shall be optimized. However, if we speak about months and probably years performance will be an issue. That's more job for SQL.

Hi @SergeiBaklan,

 

Thank you so much for this information. This gets me pretty close to what I need. However, I have a few issues with it.

 

1) On the "Jobs Corrected" query, during the remove duplicates step it is removing the record with the lower duration when it should be removing the record with the higher duration (duration - downtime). These need to be ranked somehow so the correct record can be removed. I don't have Excel Online for that command.

 

2) The "Prep Corrected" query is counting the entire value of the prep time. It should only be counting the time where a job is NOT running. For example, below it should only count the prep time from 12:09 - 12:49 = 40 minutes not 49 minutes. I think I can use the same logic that you applied to the jobs here where you subtracted the overlap with the downtime from their durations.

 

Job9/28/2023 10:229/28/2023 12:09
Prep9/28/2023 12:009/28/2023 12:49

ExcelNoob625_0-1696281124507.png

 

best response confirmed by ExcelNoob625 (Copper Contributor)
Solution

@ExcelNoob625 

Hi,

 

1) in Job Correction - add index to fix table in memory; sort by id and duration (ascending); add another index to fix in memory again, remove duplicate

 

2) corrected in Prep Corrected query

 

Please check in attached file

1 best response

Accepted Solutions
best response confirmed by ExcelNoob625 (Copper Contributor)
Solution

@ExcelNoob625 

Hi,

 

1) in Job Correction - add index to fix table in memory; sort by id and duration (ascending); add another index to fix in memory again, remove duplicate

 

2) corrected in Prep Corrected query

 

Please check in attached file

View solution in original post