Set a page as default active in report without using page name

Viewed 146

How to set a page as an default active page in my embedded report? I don't want to use the page name. Is there any other way so that whenever my report loads the page I specified is the default page?

Ex. I have page 1, page 2 and page 3 in my report, so by default page 1 loads . How could I set something so that by default page 2 loads?

Thanks in advance

1 Answers

There are two ways to do that:

  1. On Power BI service, set the page as selected and save the report. When you embed the report, that page will be displayed as default active page.
  2. Use setActive() on load event

For 2nd way, please follow the below code snippets:

a. Get a reference to the HTML element that contains the embedded report:

const embedContainer = $('#embedContainer')[0];

b. Embed the report:

const report = powerbi.embed(embedContainer, embedConfig);

c. Retrieve the page collection of your report:

const pages = await report.getPages();

d. Use page indexing to get the particular page and setActive() to set it as default active page. As per your example, you can try this:

pages[2].setActive();

Please refer:

  1. https://docs.microsoft.com/javascript/api/overview/powerbi/embed-report#example
  2. https://docs.microsoft.com/javascript/api/overview/powerbi/get-visuals#how-to-get-a-list-of-pages
  3. https://docs.microsoft.com/javascript/api/overview/powerbi/page-navigation#make-the-current-page-active
Related