Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Snmr
New Member

Copy a dataset from one workspace to another and change its source

Guys, good afternoon. I'm using powerbi embed to do some operations via code using its rest api.

What I want to do is use a base workspace (as if it were a template) and via code generate a copy of it with all its reports and datasets.

I can already create the workspace and clone the report to this new workspace, but I can't copy the data set to the new workspace. I didn't see this function either in the rest api or in the UI. I saw that through the rest api I can create the dataset by hand, but I need to inform all the tables and the type of columns in each table. I think this turns out to be unfeasible since I haven't found a way to get the metadata in the proper format to generate this new dataset.

Another approach I tried was via code to upload a data source via code to see if it generated a new dataset, but I couldn't get it to work.

Has anyone implemented something similar?

10 REPLIES 10
MRIZ
Helper II
Helper II

Hi,

I have done this task in different way. Instead of copying PBIX from worksapce, i uploaded PBIX file for my each client. In this way i got different Dataset for different clients. there is a small solution which works like below:
Problem Statement: "I have multiple clients. They wanted to see same power bi reports but they have their own databases. I can not create every report for every client one by one and deploy reports on Power BI Service workspace. And if there is a change in one report, i have to do same changes in all the reports for all of my clients."
Solution:

  1. I have created a DB which will containt two Tables (clientlist, clientreports) in MySQL.
    If anynew client comes, an entry will be made in the "Clientist" table along with its Database credentials which will be use to set Datasource Connection later. ClientReports table will have the entery of the datasets created against each client. This detail will be used for Dynamic Binding for the Datasets which helps me to achieve Single Report Serving All Clients by changing report's datasource dynamically.
  2. I have created Powershell script which is handeling all my PowerBI tasks. this script will
    - Read the clientlist table
    - Create Workspace if not created for the client
    - Read report folder which contains .PBIX files on my localsystem.
    - Deploy reports on each workspace
    - Set the datasoruce for each cleitn Dataset piblished.
    - Set the dataset refresh time
    - Update Datset connection parameters ( in my Power BI report, I have parameterize the connection 'servername' and 'databasename').
    - Set the Datasource gredentials which is connected with a Gateway.
  3. The whole process is for Power BI embedded reports using C# code present in this link
    https://github.com/microsoft/PowerBI-Developer-Samples/tree/master/.NET%20Framework
    I used servicerprincipal app own data method for embedding.
  4. I uese this link to implement Dynamic binding  Connect a Power BI report to a dataset using dynamic binding - Power BI | Microsoft Learn

 

 

Snmr
New Member

Thank you for the replies. I was able to make using pipelines via api to copy and generate a new workspace

Share the steps/solution that you tried so it can help other.

AntrikshSharma
Super User
Super User

@Snmr I have a solution but that involves downloading dataset as JSON and then generating a database out of it with Python. Would that be feasible? You will have to re-populate the datasets, and you can bind reports using REST API later.

Can u plz share the solution!!

hey @AntrikshSharma , I just reviewed the article you posted,  we are working on migrating reports across workspaces using powershell script, but it keeps creating new reports everytime we run the script, wondering if the same happens to your code too. Does it recognize the existing semantic model and overwrites it instead?

@skumar73 If I remember correctly it does overwrite existing DB.

Thanks @AntrikshSharma .

Anonymous
Not applicable

Hi @Snmr ,

If you use the feature Copy reports from other workspaces to copy the report in workspace A to workspace B, workspace B only references the dataset in Workspace A. And the dataset is not copied to Workspace B. You can copy the dataset from workspace A to workspace B by following these steps if you have the build permission for the dataset in workspace A:

1. Get the pbix file

Download a report from the Power BI service to Power BI Desktop

Download .pbix fileDownload .pbix file

2. Open the pbix file in Power BI Desktop and change the data source

How to Change Data Sources for Existing Power BI Reports - Iteration Insights

Change data sourceChange data source

3. Save it after updated the data source and publish it to workspace B

Publish from Power BI Desktop 

 

And if you need to duplicate all of the content in workspace A to workspace, please check if the following blog can help you figure out.

Duplicate workspaces using the Power BI REST APIs: a step-by-step tutorial

Best Regards

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.