26 Apr How to Replace Data Source in a Report in Power BI
In this tutorial, we’ll be looking at how we can replace data source in a report in Power BI. Replacing Data Source in a report is common when we decide to alter our data source or probably we want to connect to an online data or a database which is different from the local CSV file or excel running on our machine.
We have different approaches we can follow to achieve this which also rely on the type of data we want to replace it with.
METHOD 1
Replacing Data with the Same Connector
If the data we are connected to locally is an Excel or CSV file and we want to replace it with another file, we can do that by using the same connector. While at it we will ensure the new data has the same columns as the original one used in our report, otherwise it might result in an error.
We can replace the data by clicking on File → Options and Settings → Data Source Settings. After clicking on Data Source Settings, it brings up the image below.
Under Data Source Settings, select the Change Source button, which brings the Pop-up menu below. Click on the browse button to bring in the new file we want to replace within the report and then click Ok.
METHOD 2
Replace data with a different data source connector
Here, we want to replace our data with a new data source that is completely different from what is in the report. Let’s say we want to bring this data from SQL Server. We will show you the steps on how to go about that.
Go to the home tab and navigate to the Transform Data by clicking on it which opens up the Power Query Editor.
Under the Power Query Editor, click on New Source, which opens up a pop-up menu, for which you will locate the database you want to connect to. For us, we’ll be connecting to SQL Server database.
After clicking on SQL Server it opens up a new pop up menu to pass our credentials and then we connect. The navigator page is shown below to select the table we want to replace with in our report. We will click on the table and then select OK.
This brings us to a new page as seen below. The new data we brought in now is the newfirst_data table which is to replace ListOfOrders table.
Now, we can see that the data has been selected. Click on Advanced Editor. This Advanced Editor is where we are to perform the major work on replacing the data. After the Editor has opened, we will copy what we highlighted in the image below.
This code we copied will be pasted inside our original data Advanced editor. Now let’s do that. Click on our original data (ListOfOrders) and as well open its Advanced Editor.
The code highlighted above will be replaced with the code we copied earlier, so we have the Advanced Editor as shown below.
Then, we will click Done, whereby the data we brought in from SQL Server has been replaced with the former we had in our report. We can see the ListOfOrders Data Table has changed as shown below.
And that’s a wrap. I hope you enjoyed this post! Thanks for reading.
No Comments