How to Change Excel Data Source in Power BI

Cody Schneider8 min read

Nothing stops a reporting workflow in its tracks faster than a "Data source error" message. If your Power BI report is connected to an Excel file, changing that file's name or location can break your visuals and cause a major headache. This article will show you exactly how to change an Excel data source in Power BI using a few simple methods, from the straightforward settings menu to a more flexible approach for advanced users.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

Why Would You Need to Change a Power BI Data Source?

Before jumping into the "how," let's quickly cover the "why." You'll typically need to update a data source connection in Power BI for a few common reasons:

  • A file was moved: Someone reorganized a shared drive, or you moved the project folder on your local machine. The path Power BI once knew is no longer valid.
  • A file was renamed: The Excel file name was updated, for example, from "Sales_Data_v1.xlsx" to "Q3_Sales_Final.xlsx".
  • Migrating to the cloud: You're moving your source file from a local desktop folder to a collaborative environment like SharePoint or OneDrive to enable features like scheduled refresh.
  • Switching environments: You might have built the report using a draft or test version of an Excel file and now need to point it to the final, "production" file.

Whatever the reason, fixing this connection is usually a simple process. Let's walk through the easiest method first.

Method 1: Change The Connection Using Data Source Settings

For simple changes where you've just moved or renamed an Excel file on your local machine or a mapped network drive, this is the quickest and easiest solution. Power BI has a dedicated menu for this exact scenario.

1. Open Power BI Desktop

Start by opening your PBIX file that has the broken or outdated connection.

2. Navigate to "Transform Data"

On the Home tab of the ribbon at the top of the screen, click the Transform data button. This will open the Power Query Editor, which is where Power BI manages all of its data connections and transformations.

3. Open "Data Source Settings"

Inside the Power Query Editor, still on the Home tab, click the Data source settings button. A new window will pop up showing all the data connections in your current report.

4. Select the Source to Change

In the Data source settings window, you’ll see a list. Find and click on the Excel data source you want to update. It will be highlighted once selected.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

5. Click "Change Source..."

With the correct data source highlighted, click the Change Source... button at the bottom of the window.

6. Browse to the New File Path

Another small window will appear, showing the current file path. Click the Browse... button to open a file explorer window. Navigate to the new folder location or select the renamed Excel file.

7. Finalize and Apply the Changes

Click OK on the file path window, then click Close on the Data source settings window. Back in the Power Query Editor, you'll see a yellow bar at the top prompting you to apply the changes. Click Close & Apply. Power BI will refresh the connection, and your report visuals should load with the data from the new source file.

This method works perfectly as long as the structure of the new Excel file is the same - meaning the sheet name and column headers that your report relies on haven’t changed.

Method 2: Update the Path in the Advanced Editor

Sometimes you need more direct control or want to understand what's happening behind the scenes. The Advanced Editor shows you the M code that Power Query uses to connect to and transform your data. You can directly edit the file path here.

1. Open the Power Query Editor

Just like in the first method, open your report and go to the Home tab > Transform data to launch the Power Query Editor.

2. Select Your Excel Query

On the left side of the Power Query Editor, you'll see a pane labeled Queries. Click on the query that corresponds to your Excel file connection.

3. Go to the "Advanced Editor"

With the query selected, go to the Home tab in the ribbon and click the Advanced Editor button.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

4. Locate and Edit the File Path in the M Code

A window will pop up showing the M code for your query. The very first line, or near the top, of the code will define your Source. It will look something like this:

let
    Source = Excel.Workbook(File.Contents("C:\Users\YourName\Documents\OldSalesData\Sales_Report.xlsx"), null, true),
    Sales_Sheet = Source{[Item="Sales",Kind="Sheet"]}[Data]
    ...
in
    Sales_Sheet

The part you need to change is the text inside the parentheses after File.Contents. Carefully replace the old file path with the new one. Make sure you keep it enclosed in double quotes.

For example, if the file moved, you would change it to:

let
    Source = Excel.Workbook(File.Contents("C:\Users\YourName\Documents\NewSalesFolder\Q3\Sales_Report_Final.xlsx"), null, true),
    Sales_Sheet = Source{[Item="Sales",Kind="Sheet"]}[Data]
    ...
in
    Sales_Sheet

5. Click "Done" and Apply Changes

After you edit the path, click Done. Make sure Power Query doesn't show any syntax errors. Finally, click Close & Apply on the main Power Query ribbon to save your changes and refresh the report.

Best Practice: Switching from a Local File to SharePoint

A common scenario is migrating a local Excel file into a collaborative environment like SharePoint or OneDrive. This is a critical step if you want to use the scheduled refresh feature in the Power BI service online. In this case, simply updating the file path won't work because the connector type changes.

While you can heavily modify the M code, the most foolproof method is to grab the correct connection code from a fresh query.

  1. Get data from SharePoint: In Power Query, click New Source > More... > SharePoint Folder and connect to your site. This will create a temporary new query.
  2. Find your file: From the list of files in your SharePoint site, find the exact Excel file you're migrating to. Don't worry about transformations yet.
  3. Copy the new Source path: Open the Advanced Editor for this new temporary query. The Source line will be complex, defining the SharePoint site connection. Copy that entire first line of code.
  4. Modify your original query: Now, open the Advanced Editor for your original query (the one connected to your old local file).
  5. Paste the new Source line: Replace the old Source = Excel.Workbook(File.Contents("C:\...")) line with the SharePoint source line you just copied.
  6. Add filtering steps: After the pasted Source line, you'll need to add steps to navigate to your specific file, just as your temporary query did. You can often copy and paste these steps from the temporary query as well.
  7. Delete the temporary query: Once your original query is working and refreshed, you can safely delete the temporary query you created.

This process ensures your existing transformations are applied to the new cloud-based source file correctly.

Pro Tip: Use Parameters for Dynamic Data Sources

If you regularly switch between different files (e.g., test vs. production, or monthly sales files), repeatedly editing the code is inefficient. A much better approach is to use parameters.

1. Create a New Parameter

In the Power Query Editor, go to the Home tab, click Manage Parameters > New Parameter.

GraphedGraphed

Still Building Reports Manually?

Watch how growth teams are getting answers in seconds — not days.

Watch Graphed demo video

2. Define the Parameter

Give your parameter a name, like FilePath. Set its Type to Text. In the Current Value box, paste the full path to your Excel file (e.g., C:\Data\Sales_Q3.xlsx). Click OK.

3. Update Your Query to Use the Parameter

Go back to the Advanced Editor for your Excel query. This time, replace the hardcoded file path string with your new parameter name. The code will change from:

Source = Excel.Workbook(File.Contents("C:\Data\Sales_Q3.xlsx"), null, true)

to:

Source = Excel.Workbook(File.Contents(FilePath), null, true)

Notice there are no quotes around FilePath because you are now referring to the parameter object, not a line of text.

4. Easily Update the Data Source

Click Done and Close & Apply. Now, the next time you need to change the file, you don't have to touch the code. You can simply go to Transform data, change the value in the FilePath parameter box, and your report will automatically point to the new data source. It's a fantastic way to make your reports more flexible and easier to maintain.

Final Thoughts

Mastering how to change data sources is a fundamental skill for keeping your Power BI reports accurate and up-to-date. Using the Data source settings menu is perfect for quick fixes, while the Advanced Editor and parameters provide the control and flexibility needed for more complex or recurring reporting workflows.

Manually managing Excel files, updating paths, and wrestling with connectors is a common friction point in reporting. We've found that these tedious, manual steps are where reports most often break. This is why we created Graphed. By directly connecting your tools like Salesforce, Shopify, and Google Analytics, we remove the need to ever download CSVs or manage file paths again. You can create live dashboards that update automatically using simple conversational prompts, letting your team focus on insights instead of fixing broken data connections.

Related Articles