Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Change the Path Folder for Excel Power Query

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To change the path folder for an Excel Power Query, open the query in the Power Query Editor, find the step that contains the old file path, and either edit the path directly in the formula bar or use the Source step's settings to point to the new folder. This is a common task when you move your source files to a different drive, share a workbook with a colleague, or reorganise your folders. The exact method depends on whether the path is hard-coded in a step or stored in a parameter, and on whether the query connects to a single file or an entire folder.

What You'll Need

  • Excel with Power Query (Excel 2016 or later, or Microsoft 365). The steps below refer to the Power Query Editor, which is included in these versions.
  • The new folder path, written exactly as it appears in File Explorer (for example, C:\Reports\2024 or \\Server\Share\Data).
  • The workbook containing the query, saved and closed or open in Excel.
  • If the query uses a parameter, you will also need to know the parameter name.

Step-by-Step

  1. Open the workbook in Excel and go to the Data tab. In the Queries & Connections pane (or the Get & Transform Data group), locate the query you want to change. Double-click the query to open it in the Power Query Editor. Menu labels can differ slightly by Excel version and region.
  2. In the Power Query Editor, look at the Applied Steps list on the right side of the window. The first step is usually named Source. Click it. The formula bar below the ribbon shows the M code for that step, which typically includes the old folder path as a text string.
  3. If the Source step points to a folder, you will see a function such as Folder.Files with the path inside quotation marks. Click the gear icon next to the Source step (or right-click the step and choose Edit Settings). In the dialog that opens, replace the old path with the new folder path and click OK. Power Query will refresh the step and show the files in the new folder.
  4. If the Source step points to a single file (for example, Excel.Workbook(File.Contents("C:\Old\File.xlsx"))), you can edit the path directly in the formula bar. Click the formula bar, change the text between the quotation marks to the new full file path, and press Enter. Alternatively, use the gear icon on the Source step to browse to the new file.
  5. If the path is stored in a parameter (a separate query named something like FolderPath), close the Power Query Editor without saving changes to the main query, then edit the parameter query instead. In the Queries pane, select the parameter, change its Current Value to the new path, and click Close & Load. Then refresh the main query.
  6. After changing the path, check the subsequent steps in Applied Steps. Some steps may reference column names or file names that differ in the new folder. If a step shows an error, click it to see the message and adjust the step accordingly (for example, re-select the correct column).
  7. When the preview looks correct, click Close & Load (or Close & Load To if you want to choose where the data goes). Excel will load the data from the new path into the worksheet or data model.
  8. To confirm the change, go to the Data tab and click Refresh All. The query should refresh without prompting for the old path. If Excel asks for credentials or shows a file-not-found error, see the Troubleshooting section below.

Common Mistakes

  • Editing the path in a later step instead of the Source step. The path usually appears only in the Source step, so changing other steps will not fix the connection.
  • Forgetting to include the full path, including the drive letter or server name and the file extension. A partial path will cause a file-not-found error.
  • Using forward slashes or mixed slashes. Windows paths use backslashes; Power Query generally accepts forward slashes but may not resolve them in all cases.
  • Not updating a parameter when the query uses one. If the path is stored in a parameter, editing the main query's Source step may be overwritten on refresh.
  • Leaving the old file open in another program. Power Query may fail to read a file that is locked by Excel or another application.
  • Assuming the change applies to all queries. Each query has its own Source step, so you must repeat the change for every query that uses the old path.

Tips

  • Use a parameter for folder paths if you expect to move files often. A single parameter update then changes every query that references it.
  • Keep the new folder path in a cell in the workbook and reference it with a named range if you want non-technical users to update the path without opening the Power Query Editor. This requires a parameter query that reads the cell value.
  • Before changing the path, duplicate the query (right-click the query in the Queries pane and choose Duplicate) so you have a backup if something goes wrong.
  • Test the new path by opening it in File Explorer first. If you cannot access it there, Power Query will not be able to either.
  • If the query combines multiple files from a folder, make sure the new folder contains files with the same structure and column headers. Otherwise, the combined query may return errors or missing columns.

Troubleshooting

If the query shows a file-not-found error after the change, re-open the Power Query Editor, click the Source step, and check the path in the formula bar character by character. A missing backslash or a typo in the folder name is the most common cause. If the path is correct but the error persists, verify that the file or folder exists and that your account has permission to read it. For network paths, confirm that the share is online and that you are connected to the network.

If Excel prompts for credentials, the new location may require different authentication. In the Power Query Editor, go to Data Source Settings (under the Home tab or the Data tab depending on version) and edit the permissions for the new path. If the query loads but shows empty tables, check that the new folder contains files and that the first row is not being treated as headers incorrectly.

If a later step fails with a column-not-found error, the new files may have different column names. Click the failing step and use the gear icon to reselect the correct column, or remove the step and reapply it. If the query uses a parameter and the change does not stick after refresh, edit the parameter query directly rather than the main query. Finally, if nothing works, close the workbook without saving, reopen it, and try the change again; occasionally a stale query cache causes issues that a restart clears.

Frequently Asked Questions

Can I change the path for all queries at once?

Only if all queries reference a shared parameter. Otherwise, you must edit the Source step in each query individually.

Why does Excel still ask for the old file after I changed the path?

You may have edited a step other than Source, or the query may use a parameter that still holds the old path. Check both.

Do I need to change the path in the formula bar or in the step settings?

Either works. The gear icon on the Source step opens a dialog for browsing to the new location; editing the formula bar is faster if you know the exact path.

What happens to my data if I change the path?

The query will reload from the new location on refresh. Data already loaded into the worksheet remains until you refresh, at which point it is replaced with data from the new path.

Can I use a relative path instead of an absolute one?

Power Query does not support relative paths in the same way as Excel formulas. Use the full absolute path or a parameter.

Is it safe to edit the M code directly?

Yes, as long as you only change the text inside the quotation marks. Avoid altering function names or structure, as this can break the query.