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 script 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.
Great! Can same script be used for a workbook that is already pointing to a Power BI service workbook?
I would think so.
Hi Kasper,
Great post.
We also published a new cmdlet to PowerBIPS “Copy-PBIReports” that allows cloning multiple reports at once:
https://github.com/DevScope/powerbi-powershell-modules#CopyPBIReports
https://uploads.disquscdn.com/images/11379efe2052251d1018f370ad65b19349aecf3f71502ddb323c4cb6df1f936d.png
Great work!
awsome!
Hello Kasper,
Thank you for the detailed write up. The solution is not working for me as I’m unable to create a clientid when going to the https://dev.powerbi.com/apps site.
We’re attempting to find a way to change our existing Azure BLOB csv data source to Azure Analysis Services
Any help would be much appreciated.
unfortunately that site is down, we are working on getting it up again ASAP. You can use these steps instead to get the same clientID: https://docs.microsoft.com/en-us/power-bi/developer/register-app#register-with-the-azure-portal
Hi Kasper,
Thank you for the prompt response. I’ll give it a try.
Pete
I was able to obtain the clientID via the Azure Portal (Thank you). But when I run the script, I’m now receiving the following error message “Invoke-RestMethod : The remote server returned an error: (401) Unauthorized. + Invoke-RestMethod -Uri $uri –Headers $authHeader –Method POST -Body $ …” I checked the permissions and they seem to be ok.
Did you find a solution to this error? I am seeing the same thing.
I believe you need to be owner of the dataset. Are you ?
I am the owner of the data sets now (by taking over). But still getting the same error.
Any other pointers?
Hi Kasper,
I am even the owner of the data set and I have taken over the one where I was not. But I am still getting the same error when I am using Client Id.
Meanwhile I have gone in Azure portal and tried to give access and grant permissions from there as well but no luck. Could you please suggest.
Try this: https://docs.microsoft.com/en-us/power-bi/developer/embedded-troubleshoot it usually has to do with either no access to the dataset or not having the right App permissions.