-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'm-kovalsky/reportwrapper'
- Loading branch information
Showing
14 changed files
with
3,093 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ azure-storage-blob>=12.9.0 | |
anytree | ||
IPython | ||
polib | ||
azure.mgmt.resource | ||
azure.mgmt.resource | ||
jsonpath_ng |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"cells":[{"cell_type":"markdown","id":"5c27dfd1-4fe0-4a97-92e6-ddf78889aa93","metadata":{"nteract":{"transient":{"deleting":false}}},"source":["### Install the latest .whl package\n","\n","Check [here](https://pypi.org/project/semantic-link-labs/) to see the latest version."]},{"cell_type":"code","execution_count":null,"id":"d5cae9db-cef9-48a8-a351-9c5fcc99645c","metadata":{"jupyter":{"outputs_hidden":true,"source_hidden":false},"nteract":{"transient":{"deleting":false}}},"outputs":[],"source":["%pip install semantic-link-labs"]},{"cell_type":"markdown","id":"b195eae8","metadata":{},"source":["### Import the library and set the initial parameters"]},{"cell_type":"code","execution_count":null,"id":"1344e286","metadata":{},"outputs":[],"source":["import sempy_labs as labs\n","import sempy_labs.report as rep\n","from sempy_labs.report import ReportWrapper\n","\n","# For checking reports\n","report_name = '' # Enter the report name\n","report_workspace = None # Enter the workspace in which the report exists\n","rpt = ReportWrapper(report=report_name, workspace=report_workspace)"]},{"cell_type":"markdown","id":"4b68c027","metadata":{},"source":["### Report Best Practice Analyzer (BPA)"]},{"cell_type":"code","execution_count":null,"id":"3a596d68","metadata":{},"outputs":[],"source":["rep.run_report_bpa(report=report_name, workspace=report_workspace)"]},{"cell_type":"markdown","id":"2ac3b59a","metadata":{},"source":["#### Report BPA using custom rules"]},{"cell_type":"code","execution_count":null,"id":"bf0fe645","metadata":{},"outputs":[],"source":["import pandas as pd\n","\n","rules = pd.DataFrame(\n"," [\n"," (\n"," \"Error Prevention\",\n"," \"Semantic Model\",\n"," \"Error\",\n"," \"Fix report objects which reference invalid semantic model objects\",\n"," lambda df: df[\"Valid Semantic Model Object\"] == False,\n"," \"This rule highlights visuals, report filters, page filters or visual filters which reference an invalid semantic model object (i.e Measure/Column/Hierarchy).\",\n"," \"\",\n"," ),\n"," (\n"," \"Performance\",\n"," \"Page\",\n"," \"Warning\",\n"," \"Reduce the number of visible visuals on the page\",\n"," lambda df: df[\"Visible Visual Count\"] > 15,\n"," 'Reducing the number of visable visuals on a page will lead to faster report performance. This rule flags pages with over \" + visVisuals + \" visible visuals.',\n"," ),\n"," (\n"," \"Performance\",\n"," \"Visual\",\n"," \"Warning\",\n"," \"Reduce the number of objects within visuals\",\n"," lambda df: df[\"Visual Object Count\"] > 5,\n"," \"Reducing the number of objects (i.e. measures, columns) which are used in a visual will lead to faster report performance.\",\n"," )\n"," ],\n"," columns=[\n"," \"Category\",\n"," \"Scope\",\n"," \"Severity\",\n"," \"Rule Name\",\n"," \"Expression\",\n"," \"Description\",\n"," \"URL\",\n"," ],\n",")\n","\n","rep.run_report_bpa(report=report_name, workspace=report_workspace, rules=rules)"]},{"cell_type":"markdown","id":"5a3fe6e8-b8aa-4447-812b-7931831e07fe","metadata":{"nteract":{"transient":{"deleting":false}}},"source":["### View all semantic model objects within a report"]},{"cell_type":"code","execution_count":null,"id":"9e349954","metadata":{},"outputs":[],"source":["rpt.list_semantic_model_objects()"]},{"cell_type":"markdown","id":"9efe783e","metadata":{},"source":["#### View broken report objects (if any semantic model objects used in the report do not exist within the semantic model)\n","The 'Valid Object' column indicates if the object (measure/column/hierarchy) exists within the semantic model used by the report"]},{"cell_type":"code","execution_count":null,"id":"a7480602","metadata":{},"outputs":[],"source":["rpt.list_semantic_model_objects(extended=True)"]},{"cell_type":"markdown","id":"5fab7ef7","metadata":{},"source":["#### View broken report objects across all reports tied to a semantic model"]},{"cell_type":"code","execution_count":null,"id":"34f1d9a6","metadata":{},"outputs":[],"source":["dataset_name = '' # Enter the semantic model name\n","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)\n","labs.list_report_semantic_model_objects(dataset=dataset_name, workspace=dataset_workspace, extended=True)"]},{"cell_type":"markdown","id":"26acd665","metadata":{},"source":["### List functions within the ReportWrapper"]},{"cell_type":"code","execution_count":null,"id":"9c2c206a","metadata":{},"outputs":[],"source":["rpt.list_custom_visuals()"]},{"cell_type":"code","execution_count":null,"id":"22647267","metadata":{},"outputs":[],"source":["rpt.list_pages()"]},{"cell_type":"code","execution_count":null,"id":"493fb104","metadata":{},"outputs":[],"source":["rpt.list_visuals()"]},{"cell_type":"code","execution_count":null,"id":"1ef9a9ac","metadata":{},"outputs":[],"source":["rpt.list_visual_objects()"]},{"cell_type":"code","execution_count":null,"id":"ad00499c","metadata":{},"outputs":[],"source":["rpt.list_report_filters()"]},{"cell_type":"code","execution_count":null,"id":"c0f02a49","metadata":{},"outputs":[],"source":["rpt.list_page_filters()"]},{"cell_type":"code","execution_count":null,"id":"4cf8d12f","metadata":{},"outputs":[],"source":["rpt.list_visual_filters()"]},{"cell_type":"code","execution_count":null,"id":"3b5e9c16","metadata":{},"outputs":[],"source":["rpt.list_report_level_measures()"]},{"cell_type":"code","execution_count":null,"id":"9f420f57","metadata":{},"outputs":[],"source":["rpt.list_visual_interactions()"]},{"cell_type":"code","execution_count":null,"id":"198afff0","metadata":{},"outputs":[],"source":["rpt.list_bookmarks()"]},{"cell_type":"markdown","id":"f3ee5962","metadata":{},"source":["### Perform actions on a report\n","Set a custom theme for a report based on a Power BI theme file"]},{"cell_type":"code","execution_count":null,"id":"ec1a7d1b","metadata":{},"outputs":[],"source":["rpt.set_theme(theme_file_path='/lakehouse/default/Files/CY23SU09.json')"]},{"cell_type":"code","execution_count":null,"id":"b1203067","metadata":{},"outputs":[],"source":["rpt.set_theme(theme_file_path='https://raw.githubusercontent.com/PowerBiDevCamp/FabricUserApiDemo/main/FabricUserApiDemo/DefinitionTemplates/Shared/Reports/StaticResources/SharedResources/BaseThemes/CY23SU08.json')"]},{"cell_type":"markdown","id":"9b230f9f","metadata":{},"source":["Set whether a Power BI report page is hidden or visible"]},{"cell_type":"code","execution_count":null,"id":"8ce57483","metadata":{},"outputs":[],"source":["rpt.set_page_visibility(page_name='Page 1', hidden=True)"]},{"cell_type":"markdown","id":"ef3e4c02","metadata":{},"source":["Set the active page (page shown upon opening the report)"]},{"cell_type":"code","execution_count":null,"id":"024d4111","metadata":{},"outputs":[],"source":["rpt.set_active_page(page_name='Page 2')"]},{"cell_type":"markdown","id":"f96511ac","metadata":{},"source":["Disable the 'show items with no data' for all visuals within a Power BI report"]},{"cell_type":"code","execution_count":null,"id":"65bf38fe","metadata":{},"outputs":[],"source":["rpt.disable_show_items_with_no_data()"]},{"cell_type":"markdown","id":"ddee3565","metadata":{},"source":["Remove all custom visuals in a Power BI report which are not used in any visuals within the report"]},{"cell_type":"code","execution_count":null,"id":"9aba1564","metadata":{},"outputs":[],"source":["rpt.remove_unnecessary_custom_visuals()"]},{"cell_type":"markdown","id":"5342423f","metadata":{},"source":["Hide all pages which are used for a tooltip or drillthrough"]},{"cell_type":"code","execution_count":null,"id":"b9045cbb","metadata":{},"outputs":[],"source":["rpt.hide_tooltip_drillthrough_pages()"]}],"metadata":{"kernel_info":{"name":"synapse_pyspark"},"kernelspec":{"display_name":"Synapse PySpark","language":"Python","name":"synapse_pyspark"},"language_info":{"name":"python"},"microsoft":{"language":"python"},"nteract":{"version":"[email protected]"},"spark_compute":{"compute_id":"/trident/default"},"synapse_widget":{"state":{},"version":"0.1"},"widgets":{}},"nbformat":4,"nbformat_minor":5} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.