Search code examples
pythonpowerbistreamlit

how to integrate powerbiclient and Streamlit with QuickVisualize


I would like to use QuickVisualize to generate the dashboard as in Jupyter notebook, but I would like to apply it in Streamlit.

from powerbiclient import QuickVisualize, get_dataset_config
from powerbiclient.authentication import DeviceCodeLoginAuthentication
import pandas as pd
import streamlit as st

# Import your own CSV as a pandas data frame
df = pd.read_csv('Financial Sample.csv')

# Perform preprocessing
df = df.drop(['Month Number', 'Month Name', 'Year'], axis=1)
df = df.loc[df['Units Sold'] > 1000]
df['Discounted'] = df['Discount Band'] != 'None'

# Initiate device authentication
device_auth = DeviceCodeLoginAuthentication()

# Create a Power BI report from your data
PBI_visualize = QuickVisualize(get_dataset_config(df), auth=device_auth)

# Render new report
st.write(PBI_visualize)

Not displaying PBI_visualize


Solution

  • powerbiclient allows you to embed Power BI reports in Jupyter notebooks – I wouldn't expect this package to work out of the box in this case since you're not using the package within a Jupyter notebook. If you can convert the Power BI report to HTML, you could then embed that report in a Streamlit app via st.markdown.