What you’ll learn

These examples assume you want to interactively build a dashboard using a python script or the terminal. On this page, I’ll show how to use {powerbpy} to create a new dashboard, add pages to the dashboard, and visual elements such as maps and charts to the pages. To view dashboards you’ll need a copy of Power BI desktop and therfore using Windows.

Setup

Install dependencies

  1. Install python
    You’ll need to install python. Here are some instructions
  2. Install Power Bpy
    The {powerbpy} package isn’t on pypi yet, so you’ll need to install it from github. Open a terminal and enter the following:
py -m pip install git+https://github.com/Russell-Shean/powerbpy.git#egg=powerbpy     

After the package is on pypi, you’ll be able to install it using this:

py -m pip install powerbpy

Executing python scripts

That’s all you need to install! To create the dashboards, you’ll need to either run the commands in a terminal, or use a text editor to save the commands in a a script. I recomend starting with a text editor, because as your dashboard grows more complex, it’ll be helpful to have everything saved in a script. Many text editors have an option to execute a script directly from the editor. You can also execute the scripts from the terminal using the following command:

py build_dashboard.py

This assumes that you named your script build_dashboard.py and the command prompt’s current directory is the folder storing build_dashboard.py. You can change the current directory of the terminal using the cd command. For example you can use the following to move into C:/Users/:

cd C:/Users/

You can also use full or relative paths from the current directory to the python script without changing the current working directory. For example if you start in your %userprofile% (C:/Users/[your username]) and the python script is stored at C:/Users/[your username]/python_projects/build_dashboard.py, you can execute the script with the following:

py python_projects/build_dashboard.py    

Build dashboards

Create a new dashboard

To Create a new dashboard, you’ll need to provide two arguments:
1. parent_dir - This is the folder where you want to store your dashboard
2. report_name - This is the name you want to give your dashboard project.

If you want to create a dashboard called bigfoots in a folder called C:/Users/Russ/PBI_projects, here’s what the code should look like

# Import the package
import powerbpy as PBI


PBI.create_new_dashboard(report_location = "C:/Users/Russ/PBI_projects", report_name = "bigfoots")



# Create a new dashboard -----------------------------------------------------------------------------------------
PBI_dash.create_new_dashboard(report_location, report_name)    

If everything worked, the function should have created the following files:
image

You can open the bigfoots.pbip file in Power BI desktop normally. (Although you will probably need to turn on these preview features. )

Add a new dashboard