Do you use version control with Power BI?

Last updated by Manu Gulati [SSW] 30 days ago.See history

Foundational Concepts

Doing version control with Power BI reports used to be problematic. The primary way of doing this was to commit the .pbix file into the repository using source control tools such as Visual Studio Code (VS Code). However, this has some drawbacks:

  • Data itself gets saved to source control, which is bad as it could be large
  • Unable to see what has changed
  • Version control process is not user friendly for non-developers

bad example pbix source control
Figure: Bad example - Committing .pbix files to source control does not let you see what changed

Microsoft has addressed these issues through the introduction of:

The following video from Microsoft Build 2023 provides an overview of this.

Video: Empower every BI professional to do more with Microsoft Fabric | OD06 (Watch from min 5:00 to 13:00)

At a high-level you can set up version control as follows. Click on the links to get more detailed instructions on Microsoft Learn.

  1. Connect a workspace in Power BI Service with a branch in a Git repo in Azure DevOps
  2. Commit changes to repo through the Power BI Service
  3. Update the workspace from Git

Committing a report to the repo in this manner saves it as a Power BI Desktop Project (PBIP). A Project no longer contains a .pbix file. It instead decomposes the report into the following artifacts.

  • A Dataset folder, which contains files and folders representing a Power BI dataset
  • A Reports folder, which contains the report settings, metadata for custom visuals, etc.

Whenever you see a .pbix file it should be converted to the PBIP format.

ProjectFolders
Figure: PBIP artifacts

Developing Reports

You should no longer edit or publish reports directly in the production workspace. A better process for editing and committing reports is described below.

Business Users

If you're a business user, watch this video "Power BI Source Control for the Business User" to get a walkthrough of the process you would follow to edit and commit reports.

The entire process is done on Power BI Service (web) (except the step to create a pull request). At a high-level the steps are:

  1. Create a private workspace corresponding to the workspace where your report resides (1 time)
  2. Connect the private workspace to repo (1 time)
  3. Create new feature branch off ‘main’ (every time)
  4. Setup dataset connections (1 time) (take help from SysAdmins or Power BI Admins)
  5. Edit the report in Power BI Service (every time)
  6. Commit report to feature branch (every time)
  7. Create PR (pull request) to merge feature branch into ‘main’ on Azure DevOps (every time)
  8. Next time, create new feature branch on same workspace

If you want to update the report's data model or want more sophisticated editing features, you will need to edit the report in Power BI Desktop instead. The next section explains how you can do so.

Developers

If you're a developer, watch the video "Power BI Source Control for Developers" to get a walkthrough of the process you would follow to edit and commit reports.

The process is done on one's PC. You will need to download Power BI Desktop. At a high-level the steps are:

  1. Setup a local repository on your PC
  2. Create new feature branch off ‘origin/main’
  3. Open Power BI Desktop, and enable Power BI Projects - File | Option Settings | Options | Preview features | Power BI project (.pbip) save option
  4. Open the definition.pbir file in the “<Report Name>.Reports” folder on the local repo on your PC. This will open the report in Power BI Desktop. It will allow you to edit both the report and the dataset.

    Note: PBIP folders do not by default contain any underlying data. So when you open a definition.pbir file the visuals may show as empty. Once you refresh the report Power BI Desktop will download a copy of the data into a file called cache.abf which gets stored in a ".pbi" folder inside the Dataset folder. This file should not be saved in version control. You can create a .gitignore file to prevent Git from committing it to the repository.

PBICache
Figure: cache.abf

Gitignore
Figure: The .gitignore file

  1. Edit report in Power BI Desktop
  2. Commit report to feature branch
  3. Create PR to merge feature branch into ‘origin/main’ on Azure DevOps
  4. If you are creating a new report in Power BI Desktop, please save the report as a .pbip report (and not .pbix). You can do so via File | Save as | Select .pbip as the file type

Deploying Reports

Deployments would typically be done by Power BI Admins. You as a dev generally won't do this directly unless you're responsible for a workspace yourself.

Reports can be deployed to a production workspace by simply syncing the workspace with the 'main' branch in the Reports repository. The figure below illustrates this.

SyncChanges
Figure: Example showing how to sync changes into a workspace in Power BI Service, effectively deploying reports

We open source. Powered by GitHub