cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
runrunrun Regular Visitor
Regular Visitor

how to set page & filter to embedded report?

Hi, I want to ask some questions.

first using this guide
https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-integrate-report/

My application already work displaying power bi report

 

How to set the page & filter to that report ?

I'm using this code in my script

function postActionLoadReport() {
                // Construct the push message structure
                var m = {
                    action: "loadReport",
                    accessToken: '@TempData["accessToken"]',
                    oDataFilter: "MyTable/Location eq 'abc'",
                    pageName : 'Page 2'
                };
                message = JSON.stringify(m);
                // push the message.
                iframe = document.getElementById('iFrameEmbedReport');
                iframe.contentWindow.postMessage(message, "*");;
                iframe.contentWindow.print();
            }

but it didn't display the 'Page 2' and no filter selected.

 

And my second question is

how to set multiple filter?, so the report programmatically load the filters

 

PS: I'm new in javascript programming. Any help & references is appreaciated

Thanks.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Support Team
Community Support Team

Re: how to set page & filter to embedded report?

@runrunrun,

 

By using the new Power BI JavaScript API, you could set the load configuration properties pageName and filters.

https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

runrunrun Regular Visitor
Regular Visitor

Re: how to set page & filter to embedded report?

Thanks for the solution Sam,

Already tried using this, still can't get it to work. Any working sample without using Azure AD will be helpful.

 

My current work around is concatenating Power BI report filters with ';' as delimiter and 1 page per report.

Still using the same code 🙂

 

  // Post the access token to the IFrame
            function postActionLoadReport() {

                // Construct the push message structure
                var m = {
                    action: "loadReport",
                    accessToken: '@TempData["accessToken"]',
                    oDataFilter: "@Html.Raw(HttpUtility.JavaScriptStringEncode((string)TempData["ReportFilter"].ToString()))",
                    pageName: 'ReportSection1'
                };
                message = JSON.stringify(m);
                // push the message.
                iframe = document.getElementById('iFrameEmbedReport');
                iframe.contentWindow.postMessage(message, "*");;
                iframe.contentWindow.print();
            }

View solution in original post

5 REPLIES 5
Sunkari Member
Member

Re: how to set page & filter to embedded report?

Just want to know the answer

alopez Regular Visitor
Regular Visitor

Re: how to set page & filter to embedded report?

following 

Community Support Team
Community Support Team

Re: how to set page & filter to embedded report?

@runrunrun,

 

By using the new Power BI JavaScript API, you could set the load configuration properties pageName and filters.

https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

runrunrun Regular Visitor
Regular Visitor

Re: how to set page & filter to embedded report?

Thanks for the solution Sam,

Already tried using this, still can't get it to work. Any working sample without using Azure AD will be helpful.

 

My current work around is concatenating Power BI report filters with ';' as delimiter and 1 page per report.

Still using the same code 🙂

 

  // Post the access token to the IFrame
            function postActionLoadReport() {

                // Construct the push message structure
                var m = {
                    action: "loadReport",
                    accessToken: '@TempData["accessToken"]',
                    oDataFilter: "@Html.Raw(HttpUtility.JavaScriptStringEncode((string)TempData["ReportFilter"].ToString()))",
                    pageName: 'ReportSection1'
                };
                message = JSON.stringify(m);
                // push the message.
                iframe = document.getElementById('iFrameEmbedReport');
                iframe.contentWindow.postMessage(message, "*");;
                iframe.contentWindow.print();
            }

View solution in original post

Highlighted
Gwhiz Regular Visitor
Regular Visitor

Re: how to set page & filter to embedded report?

You have to use Power BI service and get the name from the url, it will show as "ReportSectionff84e9ab2bc3f5fb5f74"

 

Then you just plop that into the embeded URL: &pageName=ReportSectionff84e9ab2bc3f5fb5f74 and whalla, they seemed to have changed to a new URL scheme without telling us leaving us clueless when trying to embed only a certain page

Helpful resources

Announcements
October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Badges

Incoming: New and Improved Badges

Exciting news: We've given our badges an overhaul and added brand news ones.

Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Analytics in Azure virtual event

Analytics in Azure virtual event

Experience a limitless analytics service built to ingest, prep, manage, and serve data for immediate use in Power BI.

Top Kudoed Authors
Users Online
Currently online: 135 members 1,701 guests
Please welcome our newest community members: