How to Remove an Old OneDrive or T Drive Source from Excel Power Query
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.

- 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.
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.
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.
Open your Excel workbook, navigate to the 'Data' tab on the ribbon, click 'Get Data', and select 'Launch Power Query Editor'.
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.
Click on the 'Sample File' query to select it. Then, go to the 'Home' tab and click on 'Advanced Editor'.
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'.
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.

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.

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.




