Embed a Live Microsoft Power BI Report in Jupyter Notebook

Sakil Ansari
3 min readJul 3, 2020

--

Visualization tools like Power BI, Spotfire, Tableau, Click, etc play a vital role in data visualization. Visualization from these tools attracts the viewers.I am a data scientist and I am working with python technology to perform different life cycles of the data science project. When my colleagues create any report, dashboard using the above-mentioned visualization tools,I was always thinking about how can I use that report, the dashboard in my code. So finally I am able to use those visualizations in my code.

So in this post, I am going to show you how can you import the live Power BI report by using python code in jupyter notebook. Basically its very simple. Just we need to write three lines of code.

For your simplicity, I am going to show how to publish your dashboard from Power BI. Here I have used the Power BI desktop. After the creation of your dashboard,go to file — ->publish, click on the publish. You will get the message publishing to the Power BI. You will get one link(I have shown in the screenshot below), click on the link. Now you are in your Power BI service.In Power BI Service,go to file — ->Publish to web. Click on Publish to web. You will get one pop up window asking to create embed code. Just click on it. You will get another pop-up window asking to publish(shown in the screenshot below). Finally copy the URL as shown in the screenshot. below.

from IPython.display import Image
Image(filename='Figure1.PNG',width=800, height=400)
png
from IPython.display import Image
Image(filename='Figure2.PNG',width=800, height=400)
png
from IPython.display import Image
Image(filename='figure3.PNG',width=800, height=400)
png
from IPython.display import Image
Image(filename='figure4.PNG',width=800, height=400)
png
from IPython.display import Image
Image(filename='figure5.PNG',width=800, height=400)
png
from IPython.display import Image
Image(filename='figure6.PNG',width=800, height=400)
png

Python Code to read the URL

from IPython.display import IFrame

src ="https://app.powerbi.com/view?r=eyJrIjoiNmYzNjM1ODgtNjlmOS00NzU3LTlhZTctODJiYWU4MjRjMGExIiwidCI6ImY3M2E2YWU5LTM2YTgtNDg0MC1hM2MxLWY5YTI3NmE3NmMwNyJ9"
IFrame(src, width=800, height=600)
<iframe
width="800"
height="600"
src="https://app.powerbi.com/view?r=eyJrIjoiNmYzNjM1ODgtNjlmOS00NzU3LTlhZTctODJiYWU4MjRjMGExIiwidCI6ImY3M2E2YWU5LTM2YTgtNDg0MC1hM2MxLWY5YTI3NmE3NmMwNyJ9"
frameborder="0"
allowfullscreen
></iframe>

Now you can see a beautiful interactive dashboard which is created in Power BI. You can also try by creating a dashboard in any visualization tool and import the visualizations in your code. This is a small post and wants to share my thoughts to the data science community. Thank you

--

--

Sakil Ansari
Sakil Ansari

Written by Sakil Ansari

Working as a Data Scientist/ML/NLP/Speech Recognition/Deep learning

No responses yet