Power Query Problems

How to Generate Future Weekly Dates and Fill Stock Values in Power Query

John WilsonJohn Wilson Nov 10, 2026 871 views

Question details

The user needs to create missing future week-ending rows for items in Power Query and automatically carry forward the latest closing-stock value to those new rows.

How to Generate Future Weekly Dates and Fill Stock Values in Power Query
Product
Excel
Device & OS
not provided
Scenario
Managing inventory or stock data where weekly records have gaps, and the previous stock value must be carried forward to maintain an accurate ongoing inventory count.
Observed behavior
The current dataset skips weeks where no activity occurred, leaving gaps in the date sequence and missing stock values for those empty weeks.
Before you start

Ensure your dataset is formatted as an Excel Table and contains clear columns for the Item ID, Week Ending date, and Available Value.

Solution 1Recommended

Use Power Query to Generate Dates and Fill Down

Use Power Query's advanced grouping and custom function capabilities to dynamically generate a sequence of weekly dates and fill the inventory values forward.

By grouping the data by item and calculating the duration between the minimum and maximum dates, Power Query can generate a complete list of missing weekly dates. Merging this list back with your data allows you to apply a Fill Down operation to carry the last known stock value forward.

1
Open Advanced Editor

In Excel, go to Data > Get Data > From Other Sources > Blank Query. In the Power Query Editor, click the Home tab and select Advanced Editor to input your custom M code.

2
Group Data by Item

Select your Item column, navigate to the Transform tab, and click Group By to isolate the processing of date ranges for each specific item.

3
Generate Date Sequence

Use the List.Dates function in your M code to generate a sequence starting from the minimum date to the maximum date, stepping by a duration of 7 days (#duration(7, 0, 0, 0)).

4
Merge and Expand Data

Perform a Left Outer Join to merge your newly generated date table with your original source data matching on the 'Week Ending' column, then expand the 'Available Value' column.

5
Fill Down the Values

Select the newly expanded 'Available Value' column, go to the Transform tab, and click Fill > Down. This replaces the null values in the newly generated weeks with the last available closing stock value.

Use Power Query to Generate Dates and Fill Down
Performance Optimization: If you are processing hundreds of items and experiencing slow load times, go to File > Options and settings > Query Options. Under Current Workbook, select Privacy and check 'Ignore the Privacy Levels'.
Free Microsoft Office alternative

Manage Complex Inventory Data Seamlessly with WPS Office

While advanced Power Query M scripting is specific to Microsoft Excel, WPS Spreadsheet offers a robust, lightweight, and completely free alternative for managing complex datasets. Easily handle large inventory lists and perform advanced lookups without the high subscription costs.

  1. 1. Download and Install: Visit the official WPS website, download the free installation package, and install WPS Office on your device.
  2. 2. Open Your Data: Launch WPS Spreadsheet and simply open your existing Excel (.xlsx) inventory files to start managing your data.
  3. 3. Apply Formulas: Utilize the built-in formula tab to easily execute data lookups and manage missing weekly values seamlessly.
Fully compatible with Microsoft Excel (.xlsx) formats, ensuring your data opens perfectly.Supports advanced lookup formulas like XLOOKUP and VLOOKUP for comprehensive data tracking.Lightweight architecture handles large spreadsheets and thousands of item rows without lagging.Familiar interface requires zero learning curve, allowing you to migrate instantly.
microsoft office alternative - wps office

Frequently Asked Questions

Why is the Power Query Table.FillDown function not replacing my blank cells?

Table.FillDown only works on true 'null' values. If your cells contain empty strings or spaces instead of nulls, the fill down will fail. You may need to replace blank strings with nulls in the Transform tab before applying the Fill Down step.

Can I generate daily dates instead of weekly dates in Power Query?

Yes. When using the List.Dates function, change the duration parameter from #duration(7, 0, 0, 0) to #duration(1, 0, 0, 0) to step the sequence by one day at a time instead of seven.

How can I improve the processing speed of my custom Power Query function?

Complex grouping and custom functions can be resource-intensive. To speed it up, go to Query Options, disable 'Allow data previews to download in the background', and set your Current Workbook Privacy Levels to 'Ignore'.