Power Query Problems

Use Excel Power Query to Expand Employee Workdays into Daily Rows

John WilsonJohn Wilson Dec 2, 2026 868 views

Question details

Create one row per employee and working date from each person's monthly workday total.

Expand Employee Workdays into Daily Rows with Excel Power Query
Product
Microsoft Excel Power Query
Device & OS
not provided
Scenario
An employee table contains monthly workday totals that need to be assigned to dates in a selected month.
Observed behavior
The desired output lists each employee on the first N working dates of the month, excluding weekends and optionally holidays.
Before you start

In Excel, create a table named EmployeeWorkdays with Employee and Workdays columns. Enter a nonnegative whole-number total for each employee, and confirm that assigning dates from the start of the month suits your schedule.

Solution 1Recommended

Generate and expand working dates in Power Query

Use an M query to assign the first available weekdays in the selected month to each employee.

The query defaults to the current month and assigns the same first N working dates to each employee. It does not distribute workdays evenly across the month.

1
Open a blank query

In Excel, select Data > Get Data > From Other Sources > Blank Query, then open Home > Advanced Editor.

2
Paste the M code

Replace the editor contents with the following code and select Done: let MonthStart = Date.StartOfMonth(Date.From(DateTime.LocalNow())), MonthEnd = Date.EndOfMonth(MonthStart), AllDates = List.Dates(MonthStart, Duration.Days(MonthEnd - MonthStart) + 1, #duration(1, 0, 0, 0)), Holidays = {}, WorkingDates = List.Select(AllDates, each Date.DayOfWeek(_, Day.Monday) < 5 and not List.Contains(Holidays, _)), Source = Excel.CurrentWorkbook(){[Name="EmployeeWorkdays"]}[Content], AddedDates = Table.AddColumn(Source, "Work Date", each List.FirstN(WorkingDates, Number.From([Workdays])), type list), ExpandedDates = Table.ExpandListColumn(AddedDates, "Work Date"), Result = Table.TransformColumnTypes(ExpandedDates, {{"Work Date", type date}}) in Result

3
Choose a month

To use a fixed month, replace the MonthStart expression in Advanced Editor with a date such as #date(2026, 7, 1).

4
Exclude holidays if needed

Create an Excel table named Holidays with a Date column, then replace Holidays = {} with Holidays = List.Transform(Excel.CurrentWorkbook(){[Name="Holidays"]}[Content][Date], each Date.From(_)).

5
Load the results

Check the employee and Work Date rows in the preview, then select Home > Close & Load to return the results to Excel.

Generate and expand working dates in Power Query
Check the available dates: If a Workdays total exceeds the number of available working dates, the query returns only the dates available in that month. A total of zero produces no dated rows for that employee.
Free Microsoft Office alternative

Review Employee Workday Tables in WPS Spreadsheet

WPS Office is a free, lightweight Office alternative with a familiar spreadsheet interface. Open compatible Excel files to review and edit employee workday tables as you migrate; WPS does not fix Excel Power Query issues, and query refresh compatibility is not guaranteed.

Review employee workday totals and dated rows in a familiar spreadsheet interfaceOpen and edit Microsoft Excel XLSX and XLS filesUse a lightweight, free Office alternativeMove existing spreadsheet data into a familiar workspace
QA img-9

Frequently Asked Questions

How does the query exclude weekends?

The List.Select step uses Date.DayOfWeek with Day.Monday and keeps values below 5, which correspond to Monday through Friday.

How can I use a different month?

Open the query in Power Query Editor, select Home > Advanced Editor, and replace the MonthStart expression with a date such as #date(2026, 7, 1).

Can I exclude public holidays as well?

Yes. Create an Excel table named Holidays with a Date column and replace the empty Holidays list in the query with the table-based expression shown in the solution.

What happens if an employee has more workdays than available dates?

List.FirstN returns only the available working dates. Check totals against the month's weekday count after holidays are excluded.

How do I update the output after changing the employee table?

In Excel, select Data > Refresh All to rerun the query. The default month also updates based on the local current date when the query refreshes.