In April 2017 we got the ability to connect our Power BI Reports to datasets in the service (link) and that is really cool.
Today I got a question from a colleague on how to change a reports dataset in order to separate the reports from the data model – thereby having a pbix file with data model and then design reports by connecting to the dataset in the Power BI service and I came up with this workaround.
This technique can also be used if you have reports that you want to change the connection of a report to an Azure Analysis Services or copying a report to another workspace and modify the connection to a dataset in that report.
Let’s see how we can do this
In this example I have designed a data model and report that is connected to data in a SQL database
And deployed the pbix file to the service
This gives us a dataset and a report.
Now if we open the report and chose to export as pbix
Now I named the report – Demo PBI Exported.pbix
This will include the data model including all the queries etc.
If we deploy the this to the service again we will end up with 2 datasets – not a good idea – we will end up with two datamodels 😦
The best thing would be that this report was tied to the dataset in the service – but the “Get Data” doesn’t give us the option to change the connection in a file with a data model
So, I decided to create another pbix file with a connection to the Power BI
This gives me the same fields but is connected to the service
Notice that you can’t see the data and relationship in the panel to the left
So now I have 2 pbix files – one connected to the service and one with the report and the datamodel (and the original model)
First thing is to change the 2 files extension to zip – as the pbix files is just a zip file with different files within.
Now the exported pbix files listed in the picture to the right has a “large” datamodel as it includes the data and queries.
I then extracted both zip files to separate folders
I then copied the 2 files
From the pbix file connected to the service
And pasted them into the folder containing the extracted pbix file Exported from the service
I choose to overwrite the existing
Deleted the file called datamodel and zip all the files in the container to a new zip file – in this case called magic
Now change the extension to pbix and opened the file.
This will give us this look of our reports
Not exactly Magic you might say – but wait – It actually is – now go the get data and connect to the Power BI Service
And voila your report is now connected to the Power BI service
When publishing this to the service you won’t get another dataset but a new report connected to the dataset.
And even better when/if users download the report as a pbix file its connected to the service and not the data model.
Using this method also enables you to copy reports between workspaces and just point to the correct power bi service dataset.
Can it be done if we want to change connection to Azure Analysis Services – It sure can 🙂
So, I uploaded the pbix file to Azure Analysis Services to create a copy of the data model in Azure using the web-designer.
I then repeated the steps of overwriting the Connections and Mashup files in the extracted zip folder with the files from the extracted service folder.
And created a new zip file – Magic Azure AS.zip – then change the extension to pbix and opened the file.
Opened the Get Data experience and switched to Azure Group and choose Azure Analysis services database
And entered the server and database information
And the report is now connected to an Azure Analysis Services 😀
This file can now be published to any workspace as it isn’t connected to the Power BI service – dataset.
This will of course give us a new dataset in the service as it is pointing to the Azure Analysis Services
You should also check out what you can do with the Power BI Rest API if you are interested in automating the creation of reports and changing connection to data set – but you can’t do the rebinding of a report to a power bi dataset using the API’s (but it would be nice if we could)
Link to documentation about the Power BI Rest API’s – find them here
Please let me know if you find this useful by adding a comment or a like on this post.