A common questions I get is to change the connection string to from my report to SSAS after I move my Power BI desktop file into SSAS. It turns out this actually pretty simple as there is an API that allows you to copy and then bind the report to ANY dataset. Let’s walk through this.
I start with a very simple Power BI desktop file that contains a single table that I imported from SQL:
I then upload it to Power BI, I added it to it’s own app workspace.
Then I created a report that points to my local SSAS and uploaded it to the same workspace, I do this to make sure I have a dataset in Power BI that points to SSAS. If you already have a dataset present you can skip this step. Of course you have to set up a data gateway in case of using a local SSAS.
So now I have 2 datasets in my workspace (I use the same workspace but you can also have them live in different ones):
SalesIt is the dataset that points to my SSAS instance and the SalesPBI is the embedded data model. I also have the 2 reports:
Now here comes the magic. I am using a PowerShell report created by my colleague Sirui that allows you to copy and bind the new report to ANY dataset in Power BI. You can find the script here. The key thing here is to make sure the 2 schema’s are the same, it needs to have the same columns, measures, tables etc otherwise the report will throw errors. In my example I didn’t actually use a imported model but used a SQL Server 2016 RTM model with the same schema and that also works.
Ok now for the PowerShell script, it does two things:
1 It creates a copy of the report
2 It binds the new report to a dataset provided in the script
The script uses to the Power BI Clone API to clone the report and rebind it..
First we need to configure the the script, I created a new “app” on https://dev.powerbi.com/apps as described in the script to get a new client Id and set a name for my new report called “SalesNowIt”. Next I got all the ID’s needed for the script to run like report and groupId’s. The script has step by step instructions.
Now after configuring I just run the PowerShell script (no additional changes necessary). And now see a new report showing up:
And now when I run the report that previously pointed to my embedded model it still works:
But when running profiler I see queries going to my local SSAS instead of the embedded model:
So that’s it, pretty straightforward and very straightforward. Of course you can extend this PowerShell script yourself to do whatever you want, for example, loop through all the reports in a workspace and rebind them all.