In my application I'm displaying a Power BI report. It already works, so there's no problems with showing any report by its ID (guid).
But there are some reports that need to be parametrized, for instance, with current year or person who views the report. That's my question: how to do it?
To be more specific, I'm embedding the report inside HTML <iframe>
element. I set iframe URL to an URL received from report definition's embedUrl
(received from REST API). I'm controlling it by JavaScript code that calls postMessage()
.
Report definition:
{
"id":"12345678-6418-4b47-ac7c-f8ac7791a0aa",
"name":"Retail Analysis Sample",
"webUrl":"https://app.powerbi.com/reports/12345678-6418-4b47-ac7c-f8ac7791a0aa",
"embedUrl":"https://app.powerbi.com/reportEmbed?reportId=12345678-6418-4b47-ac7c-f8ac7791a0aa"
}
JavaScript code to loads the report:
function onFrameLoaded() {
var m = {
action: "loadReport",
reportId: reportId,
accessToken: accessToken
};
iframe.contentWindow.postMessage(JSON.stringify(m), "*");
}
Now I feed to filter the report by a parameter from my custom application. Is there a way to send or pass a value to filter dataset in the report?