How to Match Scheduled Time to Employee Timecards with Power Query
Question details
The user needs to accurately map scheduled times from a schedule table to an employee timecard table when there are multiple or duplicate entries for the same employee and date.

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Merging employee schedules with daily timecard records to extract scheduled time and calculate attendance, timeliness, or tardiness.
- Observed behavior
- Standard relationships or lookups fail to uniquely identify the correct scheduled time because the tables contain repeated employee and date combinations.
Ensure that both your schedule and timecard data are formatted as official Excel Tables and that you have identified the primary columns (e.g., Employee ID and Date) to be used for matching.
Add an Index Column and Merge in Power Query
Create a unique identifier by adding a grouped sequence or index column, then merge the tables based on this new compound key to handle duplicates.
When dealing with repeated combinations of dates and employees (such as multiple clock-ins in one day), a simple merge will multiply your rows. Creating an index based on the specific employee and date group ensures each timecard punch matches perfectly with its scheduled time counterpart.
Select your Schedule table, go to the Data tab, and click 'From Table/Range'. Repeat this step for your Timecard table.
In the Power Query Editor, sort both queries chronologically by clicking the drop-down on the 'Date' column and selecting 'Sort Ascending', then do the same for 'Employee ID'.
Select the 'Employee ID' and 'Date' columns. Go to Transform > Group By. Group by these columns and add an 'All Rows' operation. Then, add a Custom Column with the formula Table.AddIndexColumn([Count], "Index", 1, 1) to generate a sequential sequence for repeated records.
Go to Home > Merge Queries. Select both the schedule and timecard tables. Hold CTRL and click Employee ID, Date, and the new Index column in both tables to establish your unique matching criteria.
Click the expand icon on the newly merged column, select only the 'Scheduled Time' field, and click OK. Finally, click 'Close & Load' to return the cleaned data to Excel.

Use DAX in Power Pivot for Tardiness Calculations
If you prefer keeping tables separate in the Data Model, use DAX measures to calculate the matching scheduled time and determine employee tardiness.
Manage Employee Schedules efficiently with WPS Office
If managing complex Power Query steps or DAX formulas in Microsoft Excel feels overwhelming, WPS Office provides a highly compatible, lightweight, and completely free alternative. You can easily open your existing Excel workbooks and use built-in functions, PivotTables, and advanced filtering to manage timecards without the steep learning curve.
- 1. Download and Install: Download WPS Office for free from the official website and install it on your device.
- 2. Open Your Workbooks: Launch WPS Spreadsheet and open your existing .xlsx timecard files. All your raw data and standard functions are fully preserved.
- 3. Analyze the Data: Utilize WPS Spreadsheet's built-in formulas (like INDEX and MATCH) and PivotTables to cross-reference employee schedules efficiently.

Frequently Asked Questions
Why do I get duplicate rows when merging schedule and timecard tables?
Duplicate rows occur when an employee has multiple timecard records (like multiple clock-ins) on the same date. Because the date and employee ID combination is not entirely unique, Power Query matches every schedule entry to every timecard entry for that day. You must create an index or sequence column to establish a one-to-one relationship.
Can I use VLOOKUP or XLOOKUP instead of Power Query for this?
Standard lookup functions like VLOOKUP or XLOOKUP only return the first matching value they encounter. If an employee has multiple punches in a single day, these functions cannot accurately differentiate between the first, second, or third scheduled shift without a unique helper column (like an Index).
How can I avoid unnecessary query steps in Power Query?
To keep your queries efficient, minimize back-and-forth transformations. Sort your data and create your grouped index column in a single streamlined query before executing the merge. Avoid expanding columns you do not strictly need for your final report.




