Skip to main content

Power Bpy

Do you wish you could build dashboard with python or R, but can't because the client specifically asked for Power BI or your employer only supports publishing Power BI? Do you love love love Power BI, but wish there was a way to automatically generate parts of your dashboard to speed up your development process?

Introducing Power Bpy, a python package that lets you create Power BI dashboards using functions 💪 instead of the point-and-click interface 🥹. Dashboards created using these functions can be opened, edited and saved normally in Power BI desktop.

This package uses the new .pbip/.pbir format with TMDL enabled. This stores dashboards as directories of text files instead of binary files letting you version control your dashboards! 🥳 These features are still preview features, so use this with caution until there's more clarity from microsoft about what they're going to do with .pbir and tmdl.

pypi Version PyPI Downloads Codecov test coverage

Features

Currently the package has functions that let you automatically 🥳 do the following:

  • Create a new dashboard
  • Import data from
    • csv file stored locally
    • csv file stored in Azure Data Lake Storage (ADLS)
    • Power BI table stored as a Tabular Model Definition Language (TMDL) file
  • Add a page
  • Add background images to a page
  • Add visuals to a page
    • charts
    • slicers
    • cards
    • maps
    • text boxes
    • buttons

Dependencies

Before you can start to build power BI dashboards using this package's functions you'll need the following:

  1. python and pip installed and on path
  2. git installed and on path
  3. Power BI Desktop (You can create the dashboards without this, but not view them).

Power BI settings:
You'll need to enable some preview features in Power BI Desktop. Navigate to File > Options and Settings > Options > Preview features and enable the following options:

  1. Shape map visual
  2. Power BI Project (.pbip) save option
  3. Store Semantic Model using TMDL format
  4. Store reports using enhanced metadata format (PBIR)

Run the example

This example assumes you are on windows. All the code below should be entered in command prompt or put in a batch script.

  1. Create a new folder to store all the files you'll need.
:: create a new folder
mkdir automatic_PBI_dashboards_example

:: move into the new folder
cd automatic_PBI_dashboards_example
  1. Clone the files from github.
git clone https://github.com/Russell-Shean/PBI_dashboard_creator
  1. Activate venv.
    The following is taken from this tutorial. We'll use venv to install the python package in an isolated environemnt.
:: create a virtual environment
py -m venv .venv

:: activate the virtual environment
.venv\Scripts\activate

:: For extra credit, verify that venv is working
where python
  1. Make sure pip is installed and up-to-date.
    Pip is the tool we'll use to install the package.
:: install and/or upgrade pip
py -m pip install --upgrade pip

:: check version number (and confirm it's working)
py -m pip --version
  1. Install the package. Install the package from pypi.
py -m pip install PBI_dashboard_creator
  1. Create the example dashboard. Run an example script to generate an example dashboard.
py PBI_dashboard_creator/examples/create_example_dashboard.py
  1. Open the dashboard.
    Open the dashboard to confirm everything worked.
start test_dashboard/test_dashboard.pbip
  1. Refresh data models

After Power BI opens, you'll see a banner that looks like this: image

Click Refresh now

If everything worked you should have a dashboard that looks like this:
image
image

image

Next steps

The code used to generate the dashboard is stored here
The function documentation is stored here

Try building your own dashboards with these functions and let me know what happens!

Feedback

I welcome the following feedback:

  1. Pull requests to add features, add tests, fix bugs, or improve documentation. If the change is a major change create an issue first.
  2. Issues to suggest new features, report bugs, or tell me that the documentation is confusing 😅
  3. Power BI feature requests. I need help from Power BI developers who don't neccesarily have experience with python or github. I don't rely know Power BI 😅, so please feel free to suggest new features. It would be really helpful if you could include a .pbix file that has the feature or even better a git diff of the dashboard before and after the change.(Use the .pbip format)
  4. Tests. I need some way to test DAX, M and TMDL for validity without using Power BI desktop. If you know of a tool I could use in Github Actions let me know!

Big changes coming up:

  1. This package will be renamed as powerbpy and migrated to a different github and pypi location. The version will be reset to 0.1.0
  2. I will add a step-by-step explanation/tutorial for the example dashboard
  3. I will deploy to conda
  4. I plan to convert the functions to classes and methods
  5. I will add tests and input validation. I doubt this will do anything except prevent malformed dashboard files, but stricter input validation may break some edge case uses.
  6. I will add functions to do the following:
    • Create a map with a dynamic legend
    • Add cards and slicers
    • list pages

Metadata

Release files for PBI-dashboard-creator 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for PBI-dashboard-creator 1.2.0
File Size Uploaded
pbi_dashboard_creator-1.2.0.tar.gz 487.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for PBI-dashboard-creator 1.2.0
File Interpreter ABI Platform
pbi_dashboard_creator-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 558.1 kB

Release files / pbi_dashboard_creator-1.2.0.tar.gz

Download URL pbi_dashboard_creator-1.2.0.tar.gz
Size 487.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b74de22ab3c06fa0d74b699f9a76801d8c142fb7048702948cdecf3db2d71b51
BLAKE2b-256 checksum
How to use checksums
682e581341eff3fe88d7735fdbe3ef3c4b2a5d983fb2e7e1a3120cafccceae8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 6, 2025.

Transparency log

Release files / pbi_dashboard_creator-1.2.0-py3-none-any.whl

Download URL pbi_dashboard_creator-1.2.0-py3-none-any.whl
Size 70.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8471cbb63c6f910f2d83bb00b2b1e9afd1549671cbbf5d2332503e1e7feec1a5
BLAKE2b-256 checksum
How to use checksums
1bd4110f677aa2e775e982efa13132cfa10d650bea35f1bfe92a9bfe044881cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 6, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.62

2 release files

1.0.61

2 release files

1.0.60

2 release files

1.0.59

2 release files

1.0.58

2 release files

1.0.57

2 release files

1.0.56

2 release files

1.0.55

2 release files

1.0.54

2 release files

1.0.53

2 release files

1.0.52

2 release files

1.0.51

2 release files

1.0.50

2 release files

1.0.49

2 release files

1.0.48

2 release files

1.0.47

2 release files

1.0.46

2 release files

1.0.45

2 release files

1.0.44

2 release files

1.0.43

2 release files

1.0.42

2 release files

1.0.41

2 release files

1.0.40

2 release files

1.0.39

2 release files

1.0.38

2 release files

1.0.37

2 release files

1.0.36

2 release files

1.0.35

2 release files

1.0.34

2 release files

1.0.33

2 release files

1.0.32

2 release files

1.0.31

2 release files

1.0.30

2 release files

1.0.29

2 release files

1.0.28

2 release files

1.0.27

2 release files

1.0.26

2 release files

1.0.25

2 release files

1.0.24

2 release files

1.0.23

2 release files

1.0.22

2 release files

1.0.21

2 release files

1.0.20

2 release files

1.0.19

2 release files

1.0.17

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page