in Education by
In my application, I'm displaying a Power BI report. It already works, so there's no problem with showing any report by its ID (GUID). But there are some reports that need to be parameterized, for instance, with the 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 element. I set iframe URL to a 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? Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
Firstly, filter needs to be defined in the report, so that the user can set it manually. There are two ways to pass parameters to Power BI report from an external source In Power BI Application We can mention filter by setting filter parameter in the report URL in the address bar. The parameter takes a custom filter query: https://app.powerbi.com/groups/me/reports/12345678-6418-4b47-ac7c-f8ac7791a0a7?filter=Store/PostalCode eq '15012' "12345678-6418-4b47-ac7c-f8ac7791a0a7" is report id. "Store" is a dataset. PostalCode is a parameter to filter out. "eq" is an equality operator. After encoding the URL, it looks in this way: https://app.powerbi.com/groups/me/reports/12345678-6418-4b47-ac7c-f8ac7791a0a7?filter=Store/PostalCode%20eq%20%2715012%27 JavaScript sendMessage oDataFilter parameter JavaScript controls the loaded BI report by postMessage() calls with parameters. There is an extra option oDataFilter that can be set to filter the report. Set it in this way: oDataFilter: "Store/PostalCode eq '15012'" Here is the following code: function onFrameLoaded() { var m = { action: "loadReport", reportId: reportId, accessToken: accessToken, oDataFilter: "Store/PostalCode eq '15012'" }; iframe.contentWindow.postMessage(JSON.stringify(m), "*"); } Note: There should not be any dots in the filter parameters (data source or parameter name) as the Power BI code rejects it silently as invalid names. If you are preparing for the Power BI certification exam, then take up this Power BI online training by Intellipaat that offers instructor-led training, hands-on projects, and certification.

Related questions

0 votes
    Does anyone know of a way in Power BI to set query parameters as described here from an embed request ... for the visualization. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have an IFrame which shows a PowerBI embedded Report that having a world map. Can I pass a parameter to ... specific country. Thanks Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have an ASP.Net core 1.1 website and I want to embed Power BI reports into the site. Azure ... JsonConvert.DeserializeObject(result); Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    Does anyone know an implementation case that involves PowerBI and ElasticSearch? I was unable to find any proper documentation. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have written an SQL script which runs fine when executed directly in SQL Management Studio. However, when entering ... are removed: Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I am trying to use Microsoft Power Bi to connect to a PostgreSQL database. When I go to Get Data it just ... driving me crazy! Thanks Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I am trying to use Microsoft Power Bi to connect to a PostgreSQL database. When I go to Get Data it just ... driving me crazy! Thanks Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    I want to parse a .json column through Power BI. I have imported the data directly from the server and ... simplified parsed columns. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I'm trying to use the Power BI REST API, using an access token acquired with the "client credentials" method, ... What am I missing? Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I have been working on Power BI for a while now and I often get confused when I browse through help topics of ... two. Please guide me. Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I want to exclude specific participants from a DataFrame and create it from an existing DataFrame. I want a method ... worked for me. Select the correct answer from above options...
asked Jan 23, 2022 in Education by JackTerrance
0 votes
    Want to remove the lines from data frame from that : Have NAs across all columns a b c d e f 1 YASH00000206234 0 ... 0 1 2 3 2 Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    There is no explanation in python documentation whether parameters are passed by value or reference and why the ... actual reference? Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    Earlier I used to think that Java is Pass by Reference, but During my latest research iI came to the conclusion that ... and why is it Select the correct answer from above options...
asked Jan 21, 2022 in Education by JackTerrance
0 votes
    I find it difficult to wrap my head around developing a PowerBI visual from scratch. I was reading wiki, guide, ... thanks in advance. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
...