Power Query Problems

Excel Power Query: Preserve Manual Categories When Refreshing Folder Queries

Emma BrownEmma Brown Nov 12, 2026 869 views

Question details

The user needs to preserve manually assigned categories when an Excel Power Query folder query is refreshed with new files.

Excel Power Query: Preserve Manual Categories When Refreshing Folder Queries
Product
Microsoft Excel Power Query
Device & OS
not provided
Scenario
A folder query imports files, and manual category values are maintained beside the query output while additional files are added over time.
Observed behavior
Refreshing the query can reorder or replace output rows, causing manually entered categories to become associated with the wrong files.
Before you start

Identify a stable unique key for every file, such as the full filename or a file ID, and ensure it is included in the query output. Keep the manual category values in a separate table with a unique key column and a category column.

Solution 1Recommended

Merge a separate category mapping table into the refreshed folder query

Use this recommended approach when categories must remain attached to the correct files after new files are added or query rows are reordered.

A manually entered column beside a Power Query result is not reliably synchronized with refreshed rows. Store categories separately and join them to the query by a stable filename or other unique identifier.

1
Create the category table

In Excel, create a table containing one unique filename or file ID per row and its corresponding category. Select the range and choose Insert > Table, then give the table a clear name such as CategoryMap.

2
Load the category table into Power Query

Select any cell in the category table and choose Data > From Table/Range. In Power Query Editor, confirm that the key and category columns have the correct data types, then select Home > Close & Load To and load it as a connection.

3
Open the folder query

Select Data > Queries & Connections, right-click the folder query, and choose Edit to open it in Power Query Editor. Confirm that the output includes the same filename or unique ID used by CategoryMap.

4
Merge the queries by the stable key

In Power Query Editor, select Home > Merge Queries, choose the folder query and CategoryMap, select the matching filename or ID columns in both tables, and use a Left Outer join.

5
Expand the category column and refresh

Select the expand button on the merged CategoryMap column, keep the category field, and choose Home > Close & Load. Later, add or update categories only in CategoryMap and select Data > Refresh All.

Why this works: The category follows the stable filename or ID instead of the physical row position, so new files and refreshed sorting do not shift existing category assignments.
Free Microsoft Office alternative

Try WPS Office for Lightweight Spreadsheet Work and Excel File Compatibility

WPS Office is a free, lightweight alternative for opening, editing, and sharing common Excel workbooks. Its familiar spreadsheet interface and compatibility with Microsoft Office formats make migration easy, although Excel Power Query-specific workflows should remain in Excel.

  1. 1. Download WPS Office: Select Download WPS Office Free and install the application for your device.
  2. 2. Open the workbook: In WPS Spreadsheet, choose Menu > Open and select the .xlsx, .xls, or .csv workbook you want to review.
  3. 3. Maintain the category mapping: Create or edit a separate mapping table with stable filenames and categories, then use spreadsheet lookup functions to relate categories to refreshed data.
Open and edit common .xlsx, .xls, and .csv files with a familiar spreadsheet interface.Use lightweight spreadsheet tools for organizing filenames, category mappings, and lookup tables.Move between WPS Office and Microsoft Excel with broad Microsoft Office format compatibility.Work efficiently on Windows, macOS, Linux, and mobile devices with a streamlined office suite.
microsoft office alternative - wps office

Frequently Asked Questions

Why do manual categories move to the wrong files after a folder query refresh?

Power Query can add, remove, or reorder rows during a refresh. A manually typed value beside the output is tied to the row position, not to the file identity, so it can become associated with another file.

What key should I use to preserve categories in Power Query?

Use a value that remains unique and stable, such as the complete filename or a generated file ID. Avoid relying only on the row number because refresh operations can change row order.

Where should I store categories for a Power Query folder import?

Store them in a separate Excel table with one key column and one category column. Load that table into Power Query and use Home > Merge Queries to join it to the folder output.

Can I use XLOOKUP instead of merging the category table in Power Query?

Yes. After the query loads, add an XLOOKUP column that matches the refreshed filename or ID against the separate category table. This works when the output includes the matching key and the mapping keys are unique.

Should I type categories directly into the Power Query results?

No. Query output can be replaced or reordered during refresh, and manually entered cells are not reliably preserved. Maintain editable categories in a separate mapping table or use a carefully designed self-referencing query.