Power Query Problems

How to Match Scheduled Time to Employee Timecards with Power Query

Huma Ashraf ChHuma Ashraf Ch Oct 26, 2026 868 views

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.

How to Match Scheduled Time to Employee Timecards with Power Query and DAX
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.
Before you start

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.

Solution 1Recommended

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.

1
Load Tables to Power Query

Select your Schedule table, go to the Data tab, and click 'From Table/Range'. Repeat this step for your Timecard table.

2
Sort the Data

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'.

3
Group and Add Index

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.

4
Merge the Queries

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.

5
Expand and Load

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.

Add an Index Column and Merge in Power Query
Tip: By creating a grouped index column before merging, you prevent Power Query from creating Cartesian products (unnecessary duplicate rows) when evaluating many-to-many relationships.
Free Microsoft Office alternative

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. 1. Download and Install: Download WPS Office for free from the official website and install it on your device.
  2. 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. 3. Analyze the Data: Utilize WPS Spreadsheet's built-in formulas (like INDEX and MATCH) and PivotTables to cross-reference employee schedules efficiently.
Seamless compatibility with Microsoft Excel (.xlsx) formats and standard formulasIntuitive user interface for standard lookups, index matching, and PivotTablesLightweight application with exceptionally fast loading times for large datasetsCompletely free to download and use for your daily office productivity
microsoft office alternative - wps office

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.