Power BI Embedded is a powerful tool that allows developers to embed interactive reports and dashboards directly into their applications. One common feature many users look for in embedded reports is the ability to save bookmarks.

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

In one of the implementations for our customers, there was a requirement to retain the bookmark in the embedded report and make it available to the end user (partner) every time they navigate the app, regardless of browser type and device.

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

The first step is to create the report or dashboard. This can be done using Power BI Desktop or the Power BI service. These reports or dashboards must be embedded in the application.

2. Add the Visuals and Interactions

Once the report or dashboard has been created, add the filters, visuals, and interactions that you want to include in the bookmark.

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.

IdIntPrimary Key
NameNvarchar (50)Name of the bookmark
DisplayNameNvarchar (50)Display the name of the bookmark visible on the page
StateNvarchar (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.
ReportIdNvarchar (50)Guid of the report
UserIdIntUserId 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, 

  1. Name: Unique name of the bookmark. 
  2. Display Name: Name which would be visible to the user on the browser. 
  3. 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

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.

For deeper insights and updates on cutting-edge digital solutions transforming industries follow our page

Posted by Advaiya

    Let's connect to make technology work for you.





    Please tick the options most relevant to your business challenges
    Decision makingBusiness productivityCustomer experienceTechnology-led innovationDigital transformation


    [By using this form you agree with the storage and handling of your data by this website.]