- November 1, 2023
- Advaiya
- Business Central, Business Intelligence, Business intelligence solutions, Business operations, data analytics solutions, Digital transformation solutions, Dynamics 365 Business Central, leveraging data
Bookmarks are a great way to save the state of a report or dashboard, allowing users to easily return to that view later. This can be particularly useful for reports with many filters or interactions, enabling users to quickly jump back to a specific view they were interested in.
Scenario
Pre-requisites:
Conclusion:
- Embedded Power BI reports
- .NET application to display the Power BI embedded reports.
- SQL Server to manage/store the custom bookmarks
1. Create the Report or Dashboard
2. Add the Visuals and Interactions
3. Create Bookmarks
To capture the current state of the Power BI report, use the built-in capture, which is present in the Bookmarks Manager defined in the powerbi.js. The JavaScript file of Power BI can be downloaded from the link. This holds the current state of the report in the form of a very large base64 This token would then be stored in the database and will be used every time the reports with the same visual are opened.
Using the Ajax call, the information related to bookmarks like displayName, state, and the internal name (created so that we can differentiate between multiple bookmarks with the same name) and session-related details like current user ID and report ID on which bookmarks have been created can be saved in the database.
Click on the “Bookmark” icon in the “Visualizations” pane to create a new bookmark.
Give your bookmark a name and click “Add.” Repeat this step for each bookmark you want to create. You can now save these bookmarks in the table using Ajax call.
There is a built-in function in JavaScript of Power BI named capture, which captures the current state of the report.Â
The table to store the personal custom-created bookmarks can be saved in the table whose schema is defined.
Id | Int | Primary Key |
Name | Nvarchar (50) | Name of the bookmark |
DisplayName | Nvarchar (50) | Display the name of the bookmark visible on the page |
State | Nvarchar (MAX) | State of the Power BI report, which holds the saved information of the report. This will be used to apply changes to the Power BI report through JavaScript. |
ReportId | Nvarchar (50) | Guid of the report |
UserId | Int | UserId of the logged-in user |
4. Get Bookmarks
When the embedded report is displayed on the browser, we can get the respective bookmarks created by the specific user for that report. To get the information on those bookmarks again, an Ajax call can be used.
To fetch the information of the bookmarks coming from the Power BI service, use the bookmarksManager.getBookmarks() function, which is defined in the powerbi.js.Â
The bookmark object consists of 3 items, namely,Â
- Name: Unique name of the bookmark.Â
- Display Name: Name which would be visible to the user on the browser.Â
- State: A Base64 string that holds the information of the filters and visuals of the report/dashboard.
Â
5. Apply the Bookmarks
To apply the changes in the Power BI report, use the function applyState in the bookmarksManager. The function applyState is responsible for changing the state of the report when bookmark state is passed as the parameter.Â
Using the following steps, one can easily retain the bookmark in the embedded report.
Authored by
Deepanshi Ranka
Deepanshi Ranka is a Senior Associate in BI & Analytics team at Advaiya. She is a Microsoft certified Data Analyst and has an experience of over 3 years. She specializes in analytics, reporting and analytical tools that work seamlessly with business intelligence, data warehousing, architecture, data modelling, and cloud solutions to create effective solution models and optimize the operations.