Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Check here to see the latest version.
%pip install semantic-link-labs
import sempy_labs as labs import sempy_labs.report as rep from sempy_labs.report import ReportWrapper # For checking reports report_name = '' # Enter the report name report_workspace = None # Enter the workspace in which the report exists rpt = ReportWrapper(report=report_name, workspace=report_workspace)
rep.run_report_bpa(report=report_name, workspace=report_workspace)
import pandas as pd rules = pd.DataFrame( [ ( "Error Prevention", "Semantic Model", "Error", "Fix report objects which reference invalid semantic model objects", lambda df: df["Valid Semantic Model Object"] == False, "This rule highlights visuals, report filters, page filters or visual filters which reference an invalid semantic model object (i.e Measure/Column/Hierarchy).", "", ), ( "Performance", "Page", "Warning", "Reduce the number of visible visuals on the page", lambda df: df["Visible Visual Count"] > 15, 'Reducing the number of visable visuals on a page will lead to faster report performance. This rule flags pages with over " + visVisuals + " visible visuals.', ), ( "Performance", "Visual", "Warning", "Reduce the number of objects within visuals", lambda df: df["Visual Object Count"] > 5, "Reducing the number of objects (i.e. measures, columns) which are used in a visual will lead to faster report performance.", ) ], columns=[ "Category", "Scope", "Severity", "Rule Name", "Expression", "Description", "URL", ], ) rep.run_report_bpa(report=report_name, workspace=report_workspace, rules=rules)
rpt.list_semantic_model_objects()
The 'Valid Object' column indicates if the object (measure/column/hierarchy) exists within the semantic model used by the report
rpt.list_semantic_model_objects(extended=True)
dataset_name = '' # Enter the semantic model name dataset_workspace = None # Enter the workspace name in which the semantic model exists (if set to None it will use the workspace in which the notebook is running) labs.list_report_semantic_model_objects(dataset=dataset_name, workspace=dataset_workspace, extended=True)
rpt.list_custom_visuals()
rpt.list_pages()
rpt.list_visuals()
rpt.list_visual_objects()
rpt.list_report_filters()
rpt.list_page_filters()
rpt.list_visual_filters()
rpt.list_report_level_measures()
rpt.list_visual_interactions()
rpt.list_bookmarks()
Set a custom theme for a report based on a Power BI theme file
rpt.set_theme(theme_file_path='/lakehouse/default/Files/CY23SU09.json')
rpt.set_theme(theme_file_path='https://raw.githubusercontent.com/PowerBiDevCamp/FabricUserApiDemo/main/FabricUserApiDemo/DefinitionTemplates/Shared/Reports/StaticResources/SharedResources/BaseThemes/CY23SU08.json')
Set whether a Power BI report page is hidden or visible
rpt.set_page_visibility(page_name='Page 1', hidden=True)
Set the active page (page shown upon opening the report)
rpt.set_active_page(page_name='Page 2')
Disable the 'show items with no data' for all visuals within a Power BI report
rpt.disable_show_items_with_no_data()
Remove all custom visuals in a Power BI report which are not used in any visuals within the report
rpt.remove_unnecessary_custom_visuals()
Hide all pages which are used for a tooltip or drillthrough
rpt.hide_tooltip_drillthrough_pages()
https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fsemantic-link-labs%2Fblob%2Fmain%2Fnotebooks%2FReport%2520Analysis.ipynb
Thannks for this amazing overview of functions!
However, I do run into the foloowing issue. Reportwrapper only works with .pbir files, which is not the file type version on app.powerbi.com. Only option I come across is downloading both the file and the notebook locally. Is there a possibility to use reportwrapper while staying in fabric lakehouse environment of app.powerbi.com?
kind regards, Lidewij
Hi @mikova
thanks for this fantastic notebook. I got a general question.
rpt.list_semantic_model_objects(extended=True)
Why is this list showing me dependencies that are not really in my report? I got a lot of FALSE results in my report and after checking the visuals, I was not able to find an issue or something broken (a missing dependency).
Is there any way to programatically clean the visuals of this old/not correct information?
thanks!