logo
search
Power Query Problems

How to Remove an Old OneDrive or T Drive Source from Excel Power Query

Phi Hung VoPhi Hung Vo Sep 28, 2026 868 views

Question details

The user needs to update an Excel Power Query data source from a local or OneDrive path to a new SharePoint path to prevent refresh errors and clear the old path from settings.

How to Remove an Old OneDrive or T Drive Source from Excel Power Query
Product
Excel
Device & OS
not provided
Scenario
Moving an Excel Power Query dashboard from OneDrive or a mapped T: drive to a SharePoint folder, where old paths stubbornly remain in the data source settings.
Observed behavior
The old OneDrive or T: drive path persists in Data Source Settings and causes errors because helper queries (like Sample File) still reference the original location.
Before you start

Ensure you have the exact URL of your new SharePoint site ready and verify that you have appropriate access permissions to the files stored there.

Solution 1Recommended

Update the Source Path in Helper Queries via Advanced Editor

Manually updating the M-code in the Sample File and related function queries ensures all references point to the new SharePoint location instead of the old local drive.

When you combine files in Power Query, Excel creates 'Helper Queries' in the background. If you only change the main query source, these helper queries (like 'Sample File' and 'Transform Sample File') retain the original OneDrive or mapped drive path, causing the old source to stay in your Data Source Settings.

1
Open Power Query Editor

Open your Excel workbook, navigate to the 'Data' tab on the ribbon, click 'Get Data', and select 'Launch Power Query Editor'.

2
Locate Helper Queries

In the Queries pane on the left side of the screen, expand the 'Helper Queries' folder to find the 'Sample File' and 'Transform Sample File' queries.

3
Access the Advanced Editor

Click on the 'Sample File' query to select it. Then, go to the 'Home' tab and click on 'Advanced Editor'.

4
Replace the Connection Function

Locate the source line containing Folder.Files("T:\..."). Replace it with the SharePoint function: SharePoint.Files("https://your-sharepoint-site.com/sites/YourSite", [ApiVersion = 15]). Click 'Done'.

5
Refresh and Verify

Repeat this process for 'Transform Sample File' or any other related function queries if necessary. Once updated, click 'Close & Load' and refresh your Pivot Tables to ensure they pull data from the new SharePoint folder.

Update the Source Path in Helper Queries via Advanced Editor
Old Source Successfully Cleared: Once all helper queries no longer reference the old mapped drive, the T: drive or OneDrive path will automatically disappear from your Data Source Settings.
Free Microsoft Office alternative

Try WPS Office for Seamless Data Management

If you find Microsoft Excel's advanced Power Query settings too complex, consider trying WPS Office. As a free, lightweight, and user-friendly alternative, WPS Office provides excellent data handling, familiar spreadsheet functionality, and perfect compatibility with standard office files.

Highly compatible with Microsoft Excel formats including .xlsx, .xlsm, and .csvLightweight installation with exceptionally fast loading timesFamiliar user interface ensuring zero learning curveBuilt-in powerful data processing and pivot table features for effortless reporting
microsoft office alternative - wps office

Frequently Asked Questions

Why does the old data source still appear in Excel Data Source Settings after I changed it?

Even if you update the main query source, hidden helper queries (such as 'Sample File') often contain hardcoded references to the old OneDrive or mapped drive path. You must update these specific helper queries to clear the old source entirely.

What is the correct M-code syntax to use for a SharePoint folder?

Instead of using the local folder path formula = Folder.Files("C:\Path"), you should use the SharePoint syntax: = SharePoint.Files("https://your-domain.sharepoint.com/sites/YourSite", [ApiVersion = 15]). Make sure to only include the site URL, not the full path to the document library.

Do I need to rebuild my Pivot Tables after changing the Power Query source to SharePoint?

No, you do not need to rebuild them. As long as you correctly update the source paths in the Advanced Editor without altering the output columns of your queries, your existing Pivot Tables will refresh seamlessly using the new data.