Have you ever added a visual to a Power BI report page and published the updated report only to realize you forgot to adjust a related bookmark? It’s very easy to do. The Power BI user interface doesn’t allow you to determine which visuals are included in a bookmark that includes only selected visuals. And it takes at least 4 clicks to open the Bookmarks and Selection tabs, and then select a bookmark to see which visuals are visible or hidden when the bookmark is selected.
If you’d rather not have to click around and guess, you can parse the JSON definition of your report, or use a Fabric notebook to get information about the bookmarks in a PBIR-format report that is published in the Power BI service. What I’ll demonstrate below is a great check to perform before publishing to a higher environment (e.g., test, stage, QA, prod, whatever you call your non-dev environments).
Code walkthrough
If you aren’t using an environment with Semantic Link Labs already installed, you must do that first as shown below.
%pip install semantic-link-labsHere I import and alias the report module from Semantic Link Labs as well as pandas.
# Imports
import sempy_labs as labs
from sempy_labs import report
import pandas as pdNext I need to create a report wrapper for the report in which I want to review the bookmarks.
var_rpt = '<insert item GUID here>'
var_ws = '<insert workspace GUID here>'
var_rptw = labs.report.ReportWrapper(
report=var_rpt, workspace=var_ws,readonly=False
)The main function used here is the Semantic Link Labs list_bookmarks function, which returns a list of all bookmarks in the selected report.
The list_bookmarks function returns a DataFrame with the following columns.
df_bookmarks = var_rptw.list_bookmarks()
display(df_bookmarks)
What we see in the results above is a report with 3 bookmarks. The Sales Only bookmark includes all 7 visuals on the Dashboard page. Two of the 7 visuals are hidden. The Details bookmark includes all visuals on the Drill Details page, both of which are visible. The US2014 bookmark includes 6 visuals on the Dashboard page.

Combining list_bookmarks and list_visuals
What we see in the results above is a good start, but we need to add more information about the visuals referenced by the bookmarks. We can use the list_visuals function to get more info on each visual and then merge (join) the bookmark and visual data together for a more complete picture.
df_visuals = var_rptw.list_visuals()
df_visuals = df_visuals[['Page Name', 'Visual Name', 'Display Type',
'X', 'Y', 'Z', 'Width', 'Data Visual']]
df_bookmarks = var_rptw.list_bookmarks()
df_bookmarkvisuals = pd.merge(df_bookmarks, df_visuals,
left_on='Visual Name',
right_on='Visual Name', how='inner')
df_bookmarkvisuals = df_bookmarkvisuals.drop(columns='Page Name_y')
df_bookmarkvisuals = df_bookmarkvisuals.rename(
columns={'Page Name_x': 'Page Name'})
var_newcolumnorder = ['Bookmark Display Name', 'Bookmark Name',
'Page Display Name', 'Page Name', 'Visual Name',
'Display Type', 'Visual Hidden', 'Data Visual',
'X', 'Y', 'Z', 'Width']
df_bookmarkvisuals = df_bookmarkvisuals[var_newcolumnorder]
df_bookmarkvisuals = df_bookmarkvisuals.sort_values(
by=['Bookmark Display Name', 'Display Type', 'X', 'Y'])
display(df_bookmarkvisuals) First, I obtained the list of all visuals in the report. Then I narrowed down the column list so I only kept what was helpful for this use case. Then I got the list of bookmarks. I merged the visuals and bookmarks by performing and inner join on the Visual Name (which is really the unique GUID for the visual). After merging, I dropped the Page Name column that came from the bookmarks DataFrame and renamed the Page Name column that came from the visuals DataFrame. Then I reordered the columns to make it easier to use the final table. Finally, I sorted the values by bookmark, visual type, and then the x and y coordinates of the visual.
That gives me the following table.

This gives me a better picture of which visuals are included in each bookmark, as well as the type of visual, the location and size of the visual, and whether it is hidden in the bookmarked state.
What’s Missing?
While we can infer some of the configured properties of a bookmark based upon what is returned here, it would be nice to have it explicitly returned. When we look at the JSON that defines the bookmark, we can see:
- the bookmark display name (the name we see in the bookmarks pane)
- the bookmark name (the GUID for the bookmark)
- the page name (the GUID for the page)
- the GUIDs for the target visuals
- whether data is included in the bookmark
- if data is included, the filter expressions
- if data is included, slicer type and state
- if data is included, the sort order for a visual
- if data is included, drill location
- if data is included, the spotlight mode of a visual
What we cannot get from the Semantic Link Labs function is the visual-level info. We don’t know the filter expressions, slicer state, sort order, drill location, and spotlight mode. We also can’t tell whether the bookmark includes data or whether the bookmark includes all visuals or selected visuals. We can sort of infer whether all visuals are selected by comparing the visuals on the page to the visuals included in a bookmark, but it would be great to have an easier way. I have logged an enhancement request on Github to ask that this information be made available via Semantic Link Labs.
If you need to deep dive into your bookmarks to ensure every filter and sort order is correct, the current Semantic Link Labs solution is not for you. But if you just need to check that the bookmarks are there and which visuals are included and/or hidden, this works nicely.
More posts about Semantic Link Labs
So far, I’ve been exploring the report and admin subpackages of Semantic Link Labs. Below are some other blog posts I’ve written about them.
Check Power BI report interactions with Semantic Link Labs
Finding fields used in a Power BI report in PBIR format with Semantic Link Labs
Get Power BI Report Viewing History using Semantic Link Labs
Modify Power BI page visibility and active status with Semantic Link Labs
Enjoy!
The post Check Power BI Bookmarks with Semantic Link Labs first appeared on Data Savvy.