Power Query Problems

How to Create Overtime, Normal, and Total Rows from Excel Employee Hours

Huma Ashraf ChHuma Ashraf Ch Nov 11, 2026 868 views

Question details

The user needs to transform employee attendance data to display three distinct rows (Overtime, Normal hours, and Total) per employee for each date.

How to Create OT, Normal, and Total Rows from Excel Employee Hours Data
Product
Excel
Device & OS
not provided
Scenario
Processing employee attendance and payroll records to break down daily hours.
Observed behavior
The data needs to be reshaped to show specific breakdown rows, and any missing dates must be populated and filled with zero hours.
Before you start

Ensure your source data is formatted as an Excel Table (Ctrl+T) before importing it into Power Query. This ensures that any new attendance records added later will automatically flow into your reshaped output.

Solution 1Recommended

Use Power Query to Unpivot and Group Data

Power Query is the most reliable method to reshape data, handle missing dates, and generate automatic summary rows.

By utilizing Power Query's unpivot and grouping features, you can dynamically transform wide columns into neat rows without writing complex formulas. This approach also allows you to merge a calendar table so missing dates reflect zero hours.

1
Import Data into Power Query

Select your source table, navigate to the Data tab, and click 'From Table/Range' to open the Power Query Editor.

2
Unpivot the Hours Columns

Select the OT and Normal hours columns, right-click the headers, and choose 'Unpivot Columns'. Rename the newly created columns to 'Hour Type' and 'Hours'.

3
Merge with a Calendar Table

Create a separate query containing a complete list of dates and merge it with your employee list. Merge this combined list with your unpivoted source data to ensure all dates are covered.

4
Replace Nulls with Zeros

Select the 'Hours' column, go to the Transform tab, click 'Replace Values', and replace 'null' with '0' to fill in the missing dates.

5
Append Total Rows

Create a reference of your current query, group the data by Employee ID and Date to calculate the Sum of Hours, and label this group 'Total'. Append this grouped query back to your main unpivoted query.

6
Load the Data

Go to the Home tab and click 'Close & Load' to output the reshaped three-row format back into an Excel worksheet.

Automated Updates: Once this Power Query connection is established, you can simply click 'Refresh All' on the Data tab whenever you update the source data.

Process Employee Attendance Data Easily with WPS Spreadsheet

WPS Spreadsheet offers powerful data handling tools, including advanced array formulas and comprehensive PivotTable features, allowing you to reshape, calculate, and summarize employee hours effortlessly.

  1. 1. Open Your Data: Launch WPS Spreadsheet and open your existing employee attendance file.
  2. 2. Summarize with PivotTables: Navigate to the Insert tab and select PivotTable to quickly summarize your Normal and OT hours by Employee and Date.
  3. 3. Apply Array Formulas: Utilize built-in dynamic functions to extract unique records and stack your output rows without breaking your workbook layout.
Fully compatible with Microsoft Excel file formats (.xlsx)Supports dynamic array formulas for complex data reshapingAdvanced PivotTable capabilities for calculating total, normal, and OT hoursLightweight and completely free to use
microsoft office alternative - wps office

Frequently Asked Questions

Why are missing dates not showing up in my output?

To display missing dates, you need to create a complete calendar table and perform a Left Outer merge with your existing attendance data. After merging, you can replace any resulting null values with zeros.

Can I automate this process for future months?

Yes. By using Power Query, you set up the transformation steps once. When you paste new attendance data into your source table, simply click 'Refresh All' on the Data tab to instantly update the final output.

Is it possible to separate different types of overtime, like 1.5x and 2.0x?

Absolutely. In Power Query, simply include all your specific overtime columns when you select the columns to unpivot. The system will automatically create separate rows for each overtime category alongside the normal hours.