Skip to content
JChamboredon edited this page Sep 28, 2023 · 9 revisions

Power BI manipulation via Python

Power BI files are none other than .zip files which extension has been changed to .pbix. Unzipping a Power BI file to manipulate its contents used to result in a corrupted Power BI file:

image

Not anymore!

python-pbi

Introducing python-pbi, a Python package available on PyPI, to manipulate Power BI files via Python scripts without corrupting them. Download a report, update as required, and upload back to the Power BI service, without opening the service itself or the Power BI desktop app.

Cracking open the Power BI files

The python-pbi package can crack open a Power BI report, present its contents in organised json-like objects (report, pages, visuals, bookmarks, etc.), and modify them outside of the Power BI tools provided by Microsoft.

Automatic download and upload to the Power BI service

Use PowerShell scripts to download and upload reports from a Power BI workspace.

New features to accelerate Power BI development

Copy headers from the landing page to the rest of pages in a report. Copy pages from one report to another, along with the corresponding bookmarks, via a few Python lines!

Control different environments

Leverage the power of python-pbi to maintain dev, test, and production workspaces for your Power BI reports. Update the datasets used in the report to match the required dev, test, or production environment as you publish. Hide WIP visuals in production, or replace them by some placeholder message. Update sensitive hyperlinks during deployment to production only to prevent exposure in lower environments.

FAQ

My Power BI report is corrupted!

If you have manipulated a Power BI report via python-pbi and it gets corrupted, make sure you upload it to the Power BI service, using the steps detailed here. Most often, the report will be readable on the service, and you can edit it further manually there, or after downloading it again.

Can I copy a report page to another report, and bring the bookmarks along?

Yes! Check this example.