How to Use Power BI in Jupyter Notebook

Cody Schneider8 min read

Combining the analytical power of Python with the visual storytelling capabilities of Power BI can feel like a game-changer, and it's easier than you think to bring them together in one place. By embedding interactive Power BI reports directly into a Jupyter Notebook, you can create a complete and dynamic data narrative, from raw data processing to a shareable, polished dashboard. This article will walk you through the entire process, from installation to programmatically filtering and interacting with your reports right from your notebook.

Why Use Power BI and Jupyter Notebook Together?

At first glance, Power BI and Jupyter Notebooks might seem like they serve different purposes. Jupyter is the go-to for data scientists and analysts to clean, transform, and analyze data with Python libraries like Pandas and Scikit-learn. Power BI is a world-class business intelligence tool for creating interactive dashboards. So, why mix them?

The magic happens when you pair them up. Here’s why it’s so effective:

  • Create a Single Source of Truth: Instead of doing your analysis in a notebook and then separately creating visualizations in Power BI, you can do it all in one document. This workflow keeps your code, analysis, and final visual report seamlessly connected.
  • Add Context to Visuals: A dashboard shows what is happening, but the Python code in your notebook can show how you got there. You can document your entire data preparation and modeling process right alongside the final interactive report.
  • Automate Reporting and Filtering: As you’ll see, you can use Python to programmatically filter your embedded Power BI reports. This allows you to generate new views or customized reports for different stakeholders without ever leaving your notebook.
  • Collaborate More Easily: A Jupyter Notebook containing an embedded report can be easily shared. Colleagues can see your analysis, interact with the full Power BI report for themselves, and understand the complete data story, all from a single file.

Getting Started: Installation and Setup

Before weaving Power BI magic into your cells, you need to get your environment ready. The process is straightforward and relies on an official Python package from Microsoft.

Prerequisites

Make sure you have the following before you begin:

  • A Power BI account. A free account will work for reports in your "My Workspace," but to access reports in shared workspaces, you will typically need a Power BI Pro or Premium license.
  • Python installed on your machine.
  • Jupyter Notebook or JupyterLab installed in your Python environment.

Installing the Power BI Client Library

Microsoft has made this process simple with their powerbiclient Python package. To install it, open your terminal or command prompt and run the following command:

pip install powerbiclient

Once the installation is complete, you're ready to start authenticating and embedding your reports.

Embedding Your First Power BI Report

Now for the fun part. We'll walk through the four main steps to get your first report showing up live in your Jupyter Notebook: importing the library, authenticating your account, finding your report details, and finally, embedding it.

Step 1: Import the Necessary Libraries

Create a new Jupyter Notebook and add the following lines to your first code cell. This imports the core components for authentication and report embedding.

from powerbiclient import Report, models
from powerbiclient.authentication import InteractiveLoginAuthentication

Step 2: Authenticate Your Power BI Account

To access your reports, your notebook needs to securely log in to your Power BI account. The InteractiveLoginAuthentication method is the most direct way to do this. It opens a browser window for you to complete your login credentials, including any multi-factor authentication (MFA).

Run this code in a new cell:

# Initiate the interactive login process
auth = InteractiveLoginAuthentication()

After running this, a pop-up in your browser will prompt you to enter your Power BI credentials. Once authenticated, your notebook session will be authorized to access your Power BI resources.

Tip: If you are in an environment where a browser window isn't accessible, you can use DeviceCodeLoginAuthentication instead. It will give you a code to enter on another device to authenticate.

Step 3: Find Your Report’s Workspace ID and Report ID

Every report in Power BI has a unique identifier, and so does the workspace it lives in. The library needs these two IDs to know exactly which report to fetch and embed.

Here’s how to find them:

  1. Navigate to the report you want to embed in your browser using the Power BI service (app.powerbi.com).
  2. Look at the URL in your browser's address bar. It will be structured like this:
https://app.powerbi.com/groups/<strong>{WORKSPACE_ID}</strong>/reports/<strong>{REPORT_ID}</strong>/ReportSection...

The Workspace ID is labeled as groups in the URL, and the Report ID comes right after reports. Copy both of these long alphanumeric strings. They are the keys to your report. If you are using a report from your personal "My Workspace," the URL will have me instead of a group ID which you can use directly.

Step 4: Load and Display the Report

With your authentication object ready and your IDs in hand, you can now embed the report. Replace the placeholder text with your actual IDs and run the cell.

# Replace with your actual IDs
workspace_id = "YOUR_WORKSPACE_ID_HERE"
report_id = "YOUR_REPORT_ID_HERE"

# Create the report object
report = Report(group_id=workspace_id, report_id=report_id, auth=auth)

# Display the report in the notebook
report

And that's it! The output of the cell will render your fully interactive Power BI report. You can click on visuals, hover for tooltips, and use slicers, just as you would in the Power BI service.

Interacting with Reports Using Python

Embedding a report is already powerful, but the real advantage of this library is the ability to interact with and control the report using Python code. This opens up a new level of automation and analytical depth.

Filtering Reports Programmatically

Instead of manually clicking slicers, you can define filters in your Python code and apply them directly to the report. This is incredibly useful for generating customized views on the fly.

First, think about the filter you want to apply. You'll need the table name, the column name, and the value(s) you want to filter for. Let's say we have a sales report and we want to see data only for the "USA" and "Canada" regions.

Here’s the code to build and apply that filter:

# Import the models library if you haven't already
from powerbiclient import models

# Construct a basic filter
sales_filter = models.BasicFilter(
    target=models.Target(
        table="Sales Data",
        column="Region"
    ),
    operator="In",
    values=["USA", "Canada"]
)

# You can apply the filter when first loading the report...
report_filtered = Report(
    group_id=workspace_id,
    report_id=report_id,
    auth=auth,
    filters= [sales_filter]
)

# ...or apply it to an already embedded report
report.set_filters([sales_filter])

Once you run this, your embedded report will refresh and display the data as if you had manually selected "USA" and "Canada" in a slicer. You can create loops to generate different views of a report for every manager, region, or product category in your dataset and save or share each one individually.

Working with Pages and Bookmarks

You can also control which page of the report is displayed. First, you can get a list of all pages in the report.

# Get a list of all pages
pages = report.get_pages()

# Print the name and display name of each page
for page in pages:
    print(f"Name: {page['name']}, Display Name: {page['displayName']}")

This will give you an output like Name: ReportSection123, Display Name: Overview. Once you know the name of the page you want to see, you can activate it:

# Set the active page of the report
report.set_active_page("ReportSection123")

This same principle applies to any bookmarks you've previously saved in your Power BI report, enabling you to quickly switch to pre-configured views.

Troubleshooting Common Issues

Sometimes things don't go perfectly on the first try. Here are a few common hiccups and how to fix them:

  • Authentication Failed: If your initial authentication fails, your organization's security settings may not favor the interactive pop-up. Try using DeviceCodeLoginAuthentication as an alternative.
  • Report Not Found: A 404 or "not found" error almost always means either your workspace_id or report_id is incorrect. Double-check the URL in Power BI and make sure you've copied them exactly. Also, confirm you have permission to view that specific report.
  • Report Appears Blank: This can happen if the account you authenticated with does not have the necessary permissions to view the report's underlying dataset. Ensure permissions are set correctly in the Power BI service.

Final Thoughts

By bringing interactive Power BI reports into your Jupyter Notebook workspace, you transform your analyses into a comprehensive and dynamic story. You’re no longer just showing code or just showing a dashboard, you’re presenting the entire data journey in a single document where exploration is encouraged.

For us, this is all part of a larger mission to make data interaction more natural and immediate. Where this tutorial uses code to bridge the gap between analysis and visualization, tools like Graphed are taking the next leap. Instead of writing installation commands and authentication code, we believe you should be able to simply ask your question in plain English - like "Show me a dashboard comparing sales in the USA and Canada" - and have a live, interactive dashboard built for you in seconds. It allows you to skip straight to the insights you are looking for.

Related Articles

How to Connect Facebook to Google Data Studio: The Complete Guide for 2026

Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.

Appsflyer vs Mixpanel​: Complete 2026 Comparison Guide

The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.