Why Power BI developers should care about Power BI projects (PBIP)
Microsoft announced Power BI projects (PBIP) in the Power BI June 2023 Feature Summary. Power BI projects files (.pbip) are a new way of saving your Power BI work, an alternative to the default Power BI Desktop file (.pbix). When you save your work as a Power BI project, alongside your Power BI report, Power BI also creates a directory structure that organises your semantic model and report metadata into a set of source-control friendly folders and files. The release of Power BI projects, marks a significant first step towards making Power BI a developer tool, as the report and semantic model files can be integrated with source control systems, like Git. Now you can manage your Power BI projects in the same way as any other code artefact.
Since the initial release of Power BI project files, there have been two significant improvements to that experience:
- The adoption of Tabular Model Definition Language (TMDL) as the semantic model format for the Power BI project files.
- The introduction of the Power BI enhanced report format (PBIR) as the report format for the Power BI project files.
Power BI projects can greatly enhance your day-to-day experience of working with Power BI. In this blog post, we'll explore the key benefits of working with Power BI projects. Following this, the next two posts in this series will delve deeper into the semantic model format (TMDL) and the enhanced report format (PBIR) within Power BI projects.
New Power BI project storage format
The Power BI project storage format differs significantly from the default Power BI Desktop file (PBIX). A PBIX is an opaque binary file, so there is no meaningful way to understand the underlying code behind the semantic model and report components. In contrast, within Power BI projects, the semantic model and report definitions are contained within human-readable files that can be easily visualised and edited within a code editor.
When you save your report with the new Power BI project storage format, a directory structure is created. In the directory structure, the report and semantic model definitions are independent and split out across two folders. The '.SemanticModel' directory contains the semantic model definition in the TMDL format. There are separate TMDL files for each table, perspective, role, and culture. The '.Report' directory contains the report component definitions in the PBIR format. The PBIR format is a folder structure with separate JSON files for each report component - visual, page, bookmark etc.
Each semantic model and report definition file is source-control friendly, human-readable and can be edited with a standard code editor like Visual Studio Code (VS Code). This is significant because for the first time, we can read, edit and collaborate on the code behind the semantic model and report components.
Source control
Power BI has always had one major drawback - the lack of source control support for PBIX files. This has hindered collaboration and productivity, as we are constrained to working on the report one developer at a time, with no effective way of implementing versioning. The introduction of Power BI projects seeks to address these challenges by enabling collaboration through source control.
In Power BI projects, the semantic model and report definition files are source-control friendly and can therefore be integrated with source control systems, such as Git. Source control support for Power BI unblocks many collaboration bottlenecks. Now multiple developers can work on the same Power BI project simultaneously. You can branch versions of a semantic model or report, make separate edits, compare changes, and then merge back into a single branch - something that was impossible with PBIX files. Collaborating on a Power BI report can now follow a process similar to that of any other development project.
Source control also keeps all Power BI project source files in a central location, where you can track changes and compare differences between versions. If another developer needs to take over a Power BI project, the latest version of the semantic model and report, along with a fully tracked version history, will be available in the Git repo. This ensures that they can quickly understand all of the changes made and easily revert back to previous versions if necessary.
Continuous Integration/Continuous Deployment (CI/CD)
Implementing a CI/CD workflow for a Power BI Desktop file is not natively supported. However, it is now possible to set up a CI/CD workflow for Power BI projects using Azure DevOps/GitHub and Microsoft Fabric Git integration. This enables automated testing of Power BI semantic models and reports and their synchronisation with the Power BI service.
You can set up a workflow whereby a pull request for a Power BI project semantic model or report change in Azure DevOps/GitHub triggers a build pipeline in Azure Pipelines/GitHub Actions. This build pipeline can be set up to inspect the Power BI project semantic model and report files and perform a series of quality checks. For example, the pipeline could run a build job that cycles through the semantic model item folders and runs the Tabular Editor Best Practice Rules. If the semantic model fails a rule with higher severity, the build fails and flags the error, blocking the pull request from being completed. Only after successful validation of the Power BI project semantic model and report files, will the build pipeline succeed. After review and approval the PR can then be merged. For further insights on testing data projects, check out my colleague James Broome's talk: How to write tests for Power BI, Synapse Pipelines, Data Factory, Synapse and Databricks Notebooks.
The second part of the CI/CD workflow is enabled by Fabric Git integration. You can connect your workspace (in a Power BI Premium or Fabric capacity) to your Azure DevOps/GitHub Git repository that contains your Power BI project files. Once a connection to a branch is established, Fabric continuously monitors and tracks changes between the workspace and Git. When differences are detected, users with the appropriate permissions can permit a synchronisation process that syncs the changes on the Git branch in Azure DevOps/GitHub to the connected workspace. This process means that once a PR has been merged, the updates to semantic model or report are automatically integrated into the Power BI workspace.
CI/CD workflows provide a solid framework for managing and deploying report updates to the Power BI service. By automating the integration of report updates into the Power BI workspace, we can ensure that reports are kept up-to-date with the latest data and insights. Incorporating automated testing into the CI/CD pipelines ensures that only quality-checked and validated updates reach the production environment, reducing the risk of errors or performance issues.
Code editor support
Power BI projects enable more productive and efficient authoring of Power BI reports. PBIX files can only be edited using the Power BI Desktop interface. But now with Power BI projects, you can make edits to our Power BI report and semantic model programmatically using code editors such as VS Code.
Both the semantic model file format (TMDL) and the report file format (PBIR) have been designed to be human-readable and easily edited in a code editor. You can use any text editor to make updates to your TMDL and PBIR files, but VS Code is recommended. This is because Microsoft have developed a TMDL Language Extension for VS Code which will give you syntax highlighting. Similarly, each PBIR file has a JSON schema URL at the top of the file that provides built-in syntax validation and IntelliSense. The JSON schema is also publicly accessible and provides documentation for all of the available properties.
Code editor support really improves the Power BI development experience. You can now make batch edits to report components and DAX measures using simple scripts. You can easily copy report components, table definitions or DAX measures from one report to another. Finally, you can even programmatically create report and semantic model components leveraging re-usable component libraries and code generation techniques. Code editor support really improves the efficiency of Power BI development as it reduces the amount of manual effort that is needed, saving development time. It also improves the quality of your Power BI reports, ensuring that updates to the semantic model and report components are applied consistently.
Conclusion
Power BI projects significantly improve the Power BI development experience. By leveraging Power BI projects, developers can enable new features such as source control, support for CI/CD processes and editing Power BI reports in a code editor. These advancements will greatly improve both collaboration and productivity, improving your daily experience of working with Power BI. The next two posts in this series will deep dive into the semantic model format (TMDL) and enhanced report format (PBIR) within Power BI projects.
If you want to stay on top of all the news and articles from the Power BI ecosystem, then I'd definitely recommend signing up to endjin's free Power BI Weekly newsletter.