Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SriThiru
Frequent Visitor

Power BI embed in Jupyter notebook methods from report class won't work inside interact callback

Hi experts,

 

I'm facing a weird behaviour in powerbiclient embeded in Jupyter notebook.

Have embedded the report using the following code

from powerbiclient.authentication import MasterUserAuthentication
from powerbiclient import Report,models
#authenticate
auth_token = MasterUserAuthentication(username="xxx@yyyy.com", password="xxxx")
#embed the report

global report
report = Report(group_id="xxxxxxxx", report_id="xxxxxxxx", auth=auth_token)
report

Embedding works fine

After this I want to perform some programatic extract from the embedded report like below 

page_list = ['ReportSectiond8ab5d035cceb8586528','ReportSection1dea67c2520bce38f54f','ReportSection4b3fbaa7dd7908d906d9']
def print_visuals(ReportPage):
    print(report.visuals_on_page(ReportPage))

interact(print_visuals, ReportPage=page_list)

This would work for the first time, meaning the above code will display a dropdown, if i select a page name from the dropdown it will print the visuals of that page. But second time if I change the value in the dropdown it won't work. It won't throw any error messages. But after this behaviour, no code will run in the jupyter nook page, I have to restart the kernal.

I tried the same thing using observe event on the dropdown widget, but the same behaviour.

If I do some other operation inside the interact/observe callback function other than invoking methods from powerbiclient's report class, it will perfectly work.

Please help.

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @SriThiru ,

According to your description, it seems that it does not work properly when switching report pages. Please refer to the content in the link below and try to change the way to get the report page. See later if you can make it work properly.

Get the list of the report's pages

Embed Power BI in Jupyter Notebooks

# Get the list of pages from embedded report
pages = report.get_pages()

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yiruan-msft My problem is not about getting pages from an embedded report. The problem is any methods for example report.get_pages() won't work inside the ipywidgets's dropdown change event. 

 

from ipywidgets import interact
def dropdown_onchange(SomeOption):
    print(SomeOption)
    print(report.get_pages())
interact(dropdown_onchange,SomeOption=['one','two','three'])

 

Can you please help to solve this issue

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors