1

we are trying to implement the following:

We will have PowerBI reports for different scenarios. Each scenario has different data but it will use the same visual for the user.

Therefore, we need to have a "template" report and when a new scenario is created, new report is created from this template together with a new SQL table to which it connects.

I was surprised that it's really difficult to find information how to do this (and I think it's a quite common scenario).

From what I found so far we need to:

  1. Create pbix file which will use power query parameter for data source
  2. Upload this pbix file using REST API
  3. Call REST API to change the parameter to use correct data source

Is that process correct? If so, how to upload a pbix file to a workspace? I found only old tutorials or depricated API.

Thank you for any help.

Martin
  • 303
  • 5
  • 14

1 Answers1

0

I was surprised that it's really difficult to find information how to do this (and I think it's a quite common scenario).

Yes. Very common, but not for enterprise or self-service users, so the content can be hard to find.

Check out the Power BI Developer-in-a-day training. This is covered in module 7 Automate Solution Management.

The recommendation there is to deploy the content to a "golden workspace" and then provision a new workspace for each tenant and copy the content into the tenant workspace and configure it there.

You can automate import from the local filesystem too. The API is here, typically here you would use Post Import In Group, as the .pbix would be small.

David Browne - Microsoft
  • 80,331
  • 6
  • 39
  • 67
  • David, thanks for the helpful link. After doing some testing I think I can be more specific in what I need. I will have the "golden workspace" with the reports and datasets. When a new report needs to be cloned, I use the API to clone a report (I tested that successfully) so no need to upload .pbix file. However, this clone still points to the old dataset. I checked the documentation and I think it's possible to clone the dataset and just change the table it points to (I guess change parameter). It will take me some time though, do you know about any tutorial regarding this by any chance? – Martin Sep 23 '22 at 19:14
  • To point a report to a different Dataset use Rebind: https://learn.microsoft.com/en-us/rest/api/power-bi/reports/rebind-report-in-group – David Browne - Microsoft Sep 23 '22 at 19:19
  • I think rebind works but as the last step in my use case. Let's say I have report R with dataset D. R uses D (R -> D) When I clone R, the clone will keep the dataset D (R-clone -> D) I want to programatically create D-clone so I get R-clone -> D-clone Also, let's say that D uses Table1, I want D-clone to use Table2 – Martin Sep 23 '22 at 19:50
  • There's a script here you can use to rebind all reports in a workspace to a new dataset. https://github.com/RuiRomano/pbiscripts/blob/main/Report-Rebind-AllReportsFromWorkspaceToDataset.ps1 If you need to change the table or query, you first need to introduce a Power Query parameter, and then you change the parameter for the cloned dataset with the API here: https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/update-parameters-in-group The new table/query must, of course, have the same schema as the old one. – David Browne - Microsoft Sep 23 '22 at 23:22
  • But is there a way to clone/create a dataset? I've searched and there are APIs and articles about sharing datasets or keeping then when cloning a report. I was not successful finding an API which would simply create a new dataset from an existing one. – Martin Sep 26 '22 at 17:00
  • It’s still export + import. See https://powerbi.microsoft.com/en-us/blog/duplicating-workspaces-by-using-power-bi-cmdlets/ – David Browne - Microsoft Sep 26 '22 at 17:29
  • Thank you. I wanted to avoid something like that because it's quite complicated compared to REST API call but it may be the only way in the end. – Martin Sep 26 '22 at 19:55