How to Change Connection in Power BI

Cody Schneider8 min read

Nothing brings a dashboard project to a halt faster than a broken data connection. Whether you're moving from a test database to a live one, or a teammate simply moved a shared file, figuring out how to tell Power BI where to find the new data can be a pain. This article will walk you through exactly how to change your data connections in Power BI, from simple file path updates to more robust, flexible solutions.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Why You Might Need to Change a Data Source

Changing a report's data source is a common task, not a sign that something went wrong. Your data sources are dynamic, and your Power BI reports need to adapt. You’ll frequently find yourself needing to make this change for several reasons:

  • Moving from Development to Production: This is the most common scenario. You build your beautiful report using a safe, sandboxed development or testing database. Once it's approved, you need to point it to the live production database to see real-time information.
  • File Location Changes: A project folder gets reorganized, a file is moved from your local machine to SharePoint, or a network drive gets a new name. When the path to your source file (like an Excel or CSV file) changes, you have to update Power BI.
  • Source System Upgrades: Maybe your company is migrating from an on-premise SQL Server to an Azure SQL Database. The report stays the same, but the server details it connects to must be updated.
  • Consolidating Reports: You might have two similar reports pointing to different regional databases and want to create a master report that can easily switch between them.

Whatever the reason, the process of updating the connection isn't always obvious. Let's look at the best ways to do it.

Changing Connections in Power BI Desktop: The Two Main Methods

Power BI gives you two primary ways to update your data source connection within Power BI Desktop: the user-friendly "Data source settings" dialog and the more powerful Power Query Advanced Editor. Choosing the right one depends on your needs.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

The Easy Way: Using "Data source settings"

For simple changes like updating a server name or a file path, this is your quickest option. It's a point-and-click interface that doesn't require you to look at any code.

Example Scenario: You built a report using an Excel file located in your "Downloads" folder. Now, you’ve moved it to a shared company drive so your team can access it.

Step-by-Step Instructions:

  1. Open Data Source Settings: With your Power BI report open, go to the Home ribbon. Click the top half of the Transform data button, which opens a dropdown menu. Select Data source settings.
  2. Select the Source to Change: A dialog box will appear, listing all the data sources currently used in your report. Find and click on the Excel file connection you need to update. Once it's highlighted, click the Change Source... button at the bottom.
  3. Enter the New File Path: Another smaller window will pop up. This window is specific to the type of source you're editing. For an Excel file, it will show the current file path. Click the Browse... button to navigate to the new location of your file on the shared drive and select it. Then, click OK.
  4. Apply and Refresh: Close the Data source settings window. You'll see a yellow banner appear at the top of your report saying, "There are pending changes in your queries." Click the Apply changes button.

Power BI will now connect to the new file path and attempt to refresh your data. As long as the file structure (column names, sheet names, etc.) is the same, everything should refresh smoothly.

The Power Query Method: Using the Advanced Editor

Sometimes the simple "Change Source" button isn't enough, or maybe you want to better 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. Editing this code gives you total control.

Example Scenario: You need to change the connection to a SQL Server database, from "dev-sql-server\SALES" to "prod-sql-server\SALES".

Step-by-Step Instructions:

  1. Open the Power Query Editor: On the Home ribbon, click the Transform data button. This will launch the Power Query Editor in a new window.
  2. Select the Query: In the Queries pane on the left, select the query whose data source you want to change.
  3. Open the Advanced Editor: With the query selected, go to the Home tab within the Power Query Editor and click Advanced Editor.
  4. Locate and Edit the Source Line: A window appears showing the query's M code. Don't be intimidated! You only need to focus on the first line, which is almost always labeled "Source." It will look something like this:
let
    Source = Sql.Database("dev-sql-server\SALES", "SalesAndMarketingDB")
in
    Source

You can directly edit the text strings here. Simply change the server name:

let
    Source = Sql.Database("prod-sql-server\SALES", "SalesAndMarketingDB")
in
    Source
  1. Save and Apply: Click Done. Then, in the main Power Query Editor window, click the Close & Apply button on the top-left to save your changes and refresh your report.

Quick tip: When editing M code, even a small typo can break the query. It's smart to copy the original code from the Advanced Editor into a simple text file as a backup before you start making changes.

GraphedGraphed

Build AI Agents for Marketing

Build virtual employees that run your go to market. Connect your data sources, deploy autonomous agents, and grow your company.

Watch Graphed demo video

Best Practice: Use Parameters for Dynamic Connections

Editing connections manually works fine, but it can become repetitive if you often switch between sources (e.g., dev, test, and prod environments). A much better, more scalable approach is to use parameters.

A parameter lets you store a value, like a server name or file path, in one place. You can then reference that parameter in all your queries. When you need to change the source, you just update the parameter's value once, and every query that uses it will update automatically.

How to Create and Use a Parameter

  1. Create a New Parameter: In the Power Query Editor, go to the Home tab and click the Manage Parameters button. Select New Parameter.
  2. Configure the Parameter: In the new window, set up your parameter:

Click OK.

  1. Integrate the Parameter into Your Query: Go back to the Advanced Editor for your SQL query. Now, instead of the hardcoded server name, use the parameter you just created. Your code will change from this:
let
    Source = Sql.Database("dev-sql-server\SALES", "SalesAndMarketingDB")
in
    Source

to this:

let
    Source = Sql.Database(DatabaseServerName, "SalesAndMarketingDB")
in
    Source
  1. Close & Apply your changes.

Changing the Value of the Parameter

Now, the magic happens. The next time you need to switch all your queries to the production environment, you don't have to edit each one individually. Simply return to the Power Query editor, click Manage Parameters -> Edit Parameters, and type the new prod-sql-server\SALES value into the dialog. Every query referencing DatabaseServerName will now point to the new source instantly.

Free PDF · the crash course

AI Agents for Marketing Crash Course

Learn how to deploy AI marketing agents across your go-to-market — the best tools, prompts, and workflows to turn your data into autonomous execution without writing code.

Troubleshooting Common Connection Issues

Sometimes, changing a data source doesn't go as planned. Here are a few common hiccups and how to resolve them:

  • Permission Errors: After pointing to a new source, you might get an error about credentials. This means Power BI doesn't have permission to access the new database or file path. In the Data source settings dialog, select the source and click Edit Permissions, then Edit Credentials to enter the correct username and password.
  • Column or Table Not Found: This error pops up if the structure of the new data source is different from the old one. For example, a column was renamed from "Sales" to "Revenue." You'll need to go into the Power Query Editor. Look for the "Applied Steps" on the right side. The broken step will have a red 'X' or yellow warning icon next to it. Go to that step and correct it to reflect the new column name.
  • Privacy Level Errors: Sometimes, Power BI prevents a query from running due to an internal data firewall, usually related to data privacy levels (e.g., Private, Organizational, Public). You can manage these in Data source settings > Edit Permissions and adjust the privacy level to one that allows the connection.

Final Thoughts

Changing data sources is a fundamental skill for anyone using Power BI regularly. For quick, one-off updates, the 'Data source settings' menu is perfect. For more control and for building resilient reports, learning to use parameters in the Power Query Editor will save you a massive amount of time in the long run.

While mastering connection management in tools like Power BI is a valuable skill, it's also a reminder of the underlying friction involved in data analysis. We constantly have to connect, update, and validate sources scattered across different databases and platforms. We built Graphed to bypass this entire process. With one-click integrations for your key marketing and sales platforms like Google Analytics, Shopify, Facebook Ads, and Salesforce, you never have to worry about managing server names, API keys, or database credentials. We handle all the connections automatically, so you can go straight to asking questions in plain English and getting your dashboard built in seconds - not hours.

Related Articles