Use Excel Power Query to Distribute Downtime Across Calendar Days
Question details
Allocate each equipment downtime event to the calendar days it overlaps and prepare the daily results for reporting.

- Product
- Microsoft Excel Power Query
- Device & OS
- not provided
- Scenario
- Downtime events have separate start dates, start times, end dates, and end times and need to be reported by equipment, work type, and calendar or fiscal period.
- Observed behavior
- The desired result is one row per event and calendar day, with the overlapping downtime hours available for date-based reporting.
Put the events in an Excel table named Downtime with columns named StartDate, StartTime, EndDate, and EndTime, plus the equipment and work type keys you need for reporting. Check that the date and time values are valid and that each end datetime is later than its start datetime.
Split downtime events into daily rows with Power Query
Use this query to calculate the portion of each event that falls within each calendar day.
The query retains the source columns, creates a row for every date touched by an event, and calculates the overlap in hours. Rows with zero hours, such as an event ending exactly at midnight, are removed.
The calculation treats the supplied datetimes as local timestamps without daylight-saving or time-zone adjustments.
Select a cell in the Downtime table and choose Data > From Table/Range to open Power Query Editor.
In Power Query Editor, choose Home > Advanced Editor and replace the query with the following code. If your table or column names differ, update them in the code. let Source = Excel.CurrentWorkbook(){[Name="Downtime"]}[Content], Typed = Table.TransformColumnTypes(Source, {{"StartDate", type date}, {"StartTime", type time}, {"EndDate", type date}, {"EndTime", type time}}), AddStart = Table.AddColumn(Typed, "StartDateTime", each DateTime.From([StartDate]) + #duration(0, Time.Hour([StartTime]), Time.Minute([StartTime]), Time.Second([StartTime])), type datetime), AddEnd = Table.AddColumn(AddStart, "EndDateTime", each DateTime.From([EndDate]) + #duration(0, Time.Hour([EndTime]), Time.Minute([EndTime]), Time.Second([EndTime])), type datetime), AddDays = Table.AddColumn(AddEnd, "DowntimeDate", each List.Dates(Date.From([StartDateTime]), Duration.Days(Date.From([EndDateTime]) - Date.From([StartDateTime])) + 1, #duration(1, 0, 0, 0))), ExpandDays = Table.ExpandListColumn(AddDays, "DowntimeDate"), TypeDays = Table.TransformColumnTypes(ExpandDays, {{"DowntimeDate", type date}}), AddHours = Table.AddColumn(TypeDays, "DowntimeHours", each Duration.TotalHours(List.Min({[EndDateTime], DateTime.From([DowntimeDate]) + #duration(1, 0, 0, 0)}) - List.Max({[StartDateTime], DateTime.From([DowntimeDate])})), type number), PositiveHours = Table.SelectRows(AddHours, each [DowntimeHours] > 0) in PositiveHours
Select Done and inspect DowntimeDate and DowntimeHours in the preview. Test a multi-day event and confirm that its daily hours add up to the difference between its start and end datetimes.
Choose Home > Close & Load > Close & Load To, and select Add this data to the Data Model if it is available in your Excel version. Use Data > Relationships or Power Pivot to relate DowntimeDate and the equipment and work type keys to their corresponding dimension tables, then build a PivotTable from the model.

Review Downtime Reports in WPS Spreadsheets
WPS Office is a free, lightweight alternative with a familiar spreadsheet interface for opening and reviewing Excel reports. It supports common Office formats for easier migration, but it does not run the Excel Power Query solution described above.

Frequently Asked Questions
How are events that end at midnight allocated?
The query calculates the overlap with each day and filters out rows where DowntimeHours is zero. An event ending at midnight therefore contributes no hours to the new day.
Can I report downtime by fiscal month or week?
Yes. Add fiscal month and week fields to a date dimension table, relate its unique date column to DowntimeDate in the Data Model, and use those fields in a PivotTable.
What should I do if the Advanced Editor query reports a missing column?
Check the source table headers and edit the names in Home > Advanced Editor. The example expects StartDate, StartTime, EndDate, and EndTime and a table named Downtime.
How do I update the daily downtime after adding events?
Add the new events to the Downtime Excel table, then choose Data > Refresh All to refresh the query and any dependent model reports.




