How to Change Dataset in Power BI

Cody Schneider••8 min read

Switching the data source for an existing Power BI report can feel like a high-stakes operation, but it doesn't have to mean rebuilding everything from scratch. Whether you're moving from a test environment to production, updating a file path, or migrating to a new database, Power BI has built-in tools to make the transition smooth. This guide will walk you through the exact steps to change your dataset using the Power Query Editor, covering both the simple and the more complex scenarios.

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 Would You Need to Change a Dataset in Power BI?

Before diving into the "how," it's helpful to understand the common situations that require a data source change. This helps you recognize when this process is the right solution. You’ll typically need to do this when you're:

  • Migrating from Development to Production: One of the most frequent use cases is pointing your report from a test database or a "beta" Excel file to the live production database. This ensures your final report runs on real, official data.
  • Changing File Locations: Perhaps you built a report using an Excel file on your local desktop, but now it needs to live on a shared network drive or in a SharePoint folder so your team can access it and scheduled refreshes can happen.
  • Upgrading Your Data System: You might be modernizing your data infrastructure, meaning a report that once pulled from a collection of CSV files now needs to connect to an Azure SQL Database or another cloud-based solution.
  • Updating Credentials or Server Details: Sometimes the change is small but critical. A database server name might be updated, or you might need to connect with different credentials after a security update.

In all these cases, your report layout, visuals, and DAX measures can stay exactly as they are. You just need to tell Power BI where to look for the data now.

Understanding Your Report's Connection: Power Query

Every Power BI report is fundamentally composed of two layers: the front-end visuals (the charts, tables, and slicers you interact with) and the back-end data queries that fetch and shape the data. This back-end is managed by the Power Query Editor. When you change a dataset, you're not touching the visuals at all, you're simply editing the connection instructions in Power Query.

This is great news because it means all the hard work you put into designing your report layout won't be wasted. You're just swapping out the engine under the hood.

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.

Method 1: Change Data Source Using 'Data Source Settings' (The Easy Way)

For most straightforward changes, like updating a file path or changing a server name, the 'Data source settings' menu is your best friend. It's the simplest and most direct method.

Let's use a common example: you built a report based on an Excel file located on your computer (C:\Users\YourName\Documents\SalesData.xlsx) and now you've moved it to a shared SharePoint site.

Follow these steps:

  1. Open Power BI Desktop: Start by opening your .pbix file.
  2. Launch the Power Query Editor: On the "Home" ribbon, click the Transform data button. This will open the Power Query Editor in a new window, which is where all data connections are managed.
  3. Open Data Source Settings: In the Power Query Editor's "Home" tab, click on Data source settings. A dialog box will appear, listing every single data source currently connected to your report.
  4. Select and Change the Source: In the list, find and select the data source you need to update - in our example, the path to the original SalesData.xlsx file. Then, click the Change Source... button at the bottom.
  5. Enter the New Information: A new, smaller window will pop up. The fields here will depend on the type of data source.
  6. Apply the Changes: After updating the source, click Close on the 'Data source settings' window. Then, click Close & Apply in the top-left corner of the Power Query Editor to save your changes and refresh the report with the new data.

Power BI will now attempt to connect to the new source. If the column names and data types are the same, your report will refresh seamlessly and all visuals will populate as before.

Method 2: Edit Connections in the Advanced Editor

Sometimes, the "Change Source" button is grayed out or your connection is defined by a more complex setup. In these cases, you’ll need to directly edit the M code that defines your connection in the Advanced Editor.

This might seem intimidating, but you only need to focus on a single line of code. Let's imagine you need to change a report's connection from a staging SQL server (StagingServer_01) to the production server (ProductionServer_ABC).

  1. Open Power Query: As before, open your report in Power BI Desktop and go to Transform data.
  2. Select Your Query: On the left-hand Queries pane, select the query (which usually corresponds to a table) whose source you want to change.
  3. Open the Advanced Editor: With the query selected, go to the "Home" ribbon tab and click Advanced Editor. A window will open showing the M code behind your data transformation steps.
  4. Locate and Edit the Source Line: Look for the very first line of code, which is almost always the Source step. It will look something like this for our SQL Server example:
let
    Source = Sql.Database("StagingServer_01", "SalesDB"),
    // ... more steps here ...
in
    #"Last Step Name"

Your job is to change the server name inside the quotation marks from "StagingServer_01" to "ProductionServer_ABC". Your edited code would look like this:

let
    Source = Sql.Database("ProductionServer_ABC", "SalesDB"),
    // ... more steps here ...
in
    #"Last Step Name"
  1. Save Your Changes: Check for any syntax errors (Power BI will alert you at the bottom of the window). If everything looks good, click Done.
  2. Apply Changes and Close: Just like with the first method, click Close & Apply in the Power Query Editor. Power BI will now connect to the new production server to pull the data.
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

Tips & Best Practices for a Smooth Transition

Changing data sources can be simple, but to avoid common pitfalls, it’s wise to follow a few best practices.

Use Parameters for Server Names & File Paths

If you often switch between development and production environments, hardcoding server names or file paths is inefficient. The professional approach is to use parameters.

  1. In Power Query, go to the "Home" tab and click Manage Parameters > New Parameter.
  2. Create a parameter called something like "DBServerName" or "SharePointURL". Set its type to Text and enter the current value (e.g., StagingServer_01).
  3. Now, go back to the Advanced Editor for your query. Replace the hardcoded server name with the parameter:
Source = Sql.Database(DBServerName, "SalesDB"),

Now, to switch from staging to production, you just change the parameter's value in the main Power Query window — no need to edit the code ever again. It's a game-changer for managing different environments.

Always Back Up Your Report

Before making any major changes to a data source, save a copy of your .pbix file. Just do a "File > Save as" with a new name like MyReport_v2_backup.pbix. This gives you an instant 'undo' button if something goes wrong.

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.

Verify Data Structure Compatibility

The biggest cause of errors during a data source change is a mismatch in the "schema" or structure of the data. For the swap to be seamless, the new data source must have:

  • The same table or sheet names.
  • The same column headers.
  • Similar data types in each column (e.g., a "Sales" column that was a number can't suddenly become text).

If these don’t match, Power Query will generate errors, and your report visuals that depend on the missing or changed columns will break.

Check and Edit Permissions

After you point to a new data source, you may need to provide new credentials. You can manage this in Data source settings. Select the new source, click Edit Permissions, and enter the necessary username/password or authenticate your account.

Final Thoughts

Changing a Power BI dataset is a core skill that moves you from a casual user to someone who can confidently manage and maintain reports long-term. By using the 'Data Source Settings' panel for simple swaps or the 'Advanced Editor' for more complex ones, you can easily ensure your reports always point to the right data without having to rebuild your visuals.

Managing data connections and manually updating reports can quickly consume valuable time, especially as your data sources grow. At our company, we streamlined this entire process so you never have to mess with M code or data source settings again. With Graphed, you connect your business platforms like databases, ad accounts, and CRMs with one-click integrations. Dashboards stay live and updated automatically, and instead of wrestling with settings, you simply ask in plain English for the data you want to see — letting you focus on insights, not on manual data wrangling.

Related Articles