Leverage Sourcetree for Power BI Enhanced Report Format (PBIR)

Leverage Sourcetree for Power BI Enhanced Report Format (PBIR)

In June24, Power BI has announced an public review of Power BI enhanced report format (PBIR) for Power BI Project files (PBIP). This is a significant enhancement of source control in Power Bi project. Today, I am going to talk about how to use Sourcetree for as Git flow to control the source code in this.


Use Case

PBIP is in preview for a while and it is a milestone for some advanced developer but just an normal update for other. why?

  1. In contrast to software development, Power BI report development cycle involve less coordination and collaboration in the developing staging. e.g. Usually a report\semantic model is assigned to one developer rather than a group of them.
  2. In CI/CD stage, it is quite a overhead to create and maintain an environment for that. Despite of this,

Despite the above reason, having Power BI project as code for developer has a massive benefit in batch change. which I would like to quote from the release "simply copy & paste visuals/pages/bookmarks/… files between reports or apply manual/programmatic batch changes to the PBIR files."

Microsoft has been trying to make the end to end (from desktop to online service) Git integration with only one string attached-- Premium license. Of course, you pay what you got. But from non software development organization to a fully adapt source control for Power BI project , it is like transiting from 0 to 1, which sometimes is impossible to convince the decision maker to endorse and sponsor the move toward that. Is there any other way in between? The answer is Yes. Use Sourcetree as free Git repo for version control in conjunction with Visual Studio Code.

Prerequisites

Let's do a bit more deep dive into it. with Power BI enhanced report format (PBIR) for Power BI Project files (PBIP), it is basically decompose a binary PBIX file into a series of JSON files in a structured folder, similar to the principle of open-source projects that allow more collaborative and transparent approach to manage Power BI projects. So the prerequisites for this is,

  1. Power BI Desktop with a pro license
  2. Visual Studio Code as a coding environment.
  3. Sourcetree as source control to visually manage the change

There are a lot of substitute tools in the market for the second and third. One can even say Visual Studio Code (VS Code) can be used as source control. Well, there is nothing wrong with that. It is just the Sourcetree provide better GUI then VS Code which I personally compared and found it take my worries away for source control and focus on coding only, hence highly recommended. Another reason is that it also support version control for binary file with no coding option. So let me do a demo to show you how to set up these three tools in your development work.

The Action

  1. Download and install VS Code and Sourcetree
  2. Open the PBIX file in Power BI and save the Power BI report as PBIP
  3. Open VS code and open folder and select the project folder where the PBIP files are saved. As mentioned before, PBIR report format is a breakdown of JSON files in structured folder as metadata. So loading a folder in is usually the best way to manage the code, unless you want only a change on the specific code as a ad hoc task rather than a project.

Once open the folder will be shown as following.

  • Report is the the visualization that is the same as what you see when you publish to Power BI service
  • SemanticModel is the data model behind the report
  • gitignore is to ensure that certain files not tracked by Git remain untracked
  • PBIP file is the shortcut to the report folder, which you can use to open the file in Power BI Desktop



4. Open Sourcetree. when open it first time, you have to set up the repo for it to work. As mentioned, Power BI development is likely a lightweight project so a local repo is more than enough, compared to a remote repo which is more for collaboration purpose. Here is the steps.

1). In New tab, the default repo is local, click on create.

2). Browse the folder where you save the PBIP into. Then create.

3). Once created. It will automatically create a main branch and all the files in the folder will be listed there. you can basically stage all of them and commit it with the comment as Initial commit.

Initial commit


5. Now here is the exciting part. Go back to Power BI and make some change and save the change. Sourcetree will be smart enough to pick up the change as new commit shown on top left (uncommitted change ) and ask for commit. Similar to the initial commit, here is the step.

New commit

6. Got back to VS Code, since the change is committed, VS Code will detect the committed change and it won't show any more commit. The other way is that you can commit change in VS Code and Sourcetree will update the commit as well. These two tools are synced together!


By doing it, you can save the PBIP file each time and with comment or you can save the file multiple times and commit once. If something goes wrong, you can rollback to any version of commit you previous have as follow

Simple way of rollback with hard mode


This is just the beginning of fun. To have a bit more complicate version control, you can think of Gitflow as a branching model which you can implement for your project. This will help you to have different branch for different purpose (e.g. feature1, feature2. hotfix1, hotfix2 etc.) To simplify the branching strategy, My rule-of-thumbs is to keep the master as raw code and only merge with the other branches when they has been tested and endorsed. Develop branch is just a separation from production which I find not too much of use as we can always rollback.


Git-Flow branching model

So this is quick demo of Sourcetree GUI. You can see it is far more sophisticate than source control in VS code. Another reason to use Sourcetree is for any other project that it doesn't has code as source, it also works perfectly as a proper version control. I tried it with a PBIX file and you can still do all branching and commit. The only thing missing is that there is no coding involved for you to see what exactly the change in code, it is merely a binary file as a whole. Still the advantage is that you don't need to save the binary file as different name for different versions.

I hope this article can give you an alternative to have a Git in Power BI project using Sourcetree. As you can see, a fully integrated CI/CD development pipeline requires a lot of setting like DevOps for collaboration and release control on top of abovementioned tools. but for lightweight and free alternative version control using Git branching model, this is a must have. After all, not all organizations can afford to have a DevOps developer to support the set up of Power BI project, Power BI developer should be the one to familiar with these tools to make your development more efficient.


要查看或添加评论,请登录

Gavin Lin的更多文章

社区洞察

其他会员也浏览了