Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hey everyone,
I am developing a web app using Power Bi Embedded (using javascript sdk), and I have two doubts.
1. It is still not clear how to get the access token. Should I just make a post request to the api (https://api.powerbi.com/v1.0/myorg/groups/{group_Id}/reports/{report_id}/GenerateToken)?
2. I want to be able to filter my report even before it loads, ( I am creating an app so my clients can see their data through a Power Bi report, but I want to filter it by their IDs even before it loads, because one client may not see each other data) is it possible to do so?
Thank you very much.
Solved! Go to Solution.
Q1. You can follow these instructions to generate a token. You will need to know C#.
https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding-content/
Q2. The filtering you are describing is called RLS(Row Level Security). You can pass in role when generating your token request that would allow each client to see their own data.
var generateTokenRequestParameters = new GenerateTokenRequest("View", null, identities: new List<EffectiveIdentity> { new EffectiveIdentity(username: "username", roles: new List<string> { "roleA", "roleB" }, datasets: new List<string> { "datasetId" }) }); var tokenResponse = await client.Reports.GenerateTokenInGroupAsync("groupId", "reportId", generateTokenRequestParameters);
Q1. You can follow these instructions to generate a token. You will need to know C#.
https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding-content/
Q2. The filtering you are describing is called RLS(Row Level Security). You can pass in role when generating your token request that would allow each client to see their own data.
var generateTokenRequestParameters = new GenerateTokenRequest("View", null, identities: new List<EffectiveIdentity> { new EffectiveIdentity(username: "username", roles: new List<string> { "roleA", "roleB" }, datasets: new List<string> { "datasetId" }) }); var tokenResponse = await client.Reports.GenerateTokenInGroupAsync("groupId", "reportId", generateTokenRequestParameters);
2. I want to be able to filter my report even before it loads, ( I am creating an app so my clients can see their data through a Power Bi report, but I want to filter it by their IDs even before it loads, because one client may not see each other data) is it possible to do so?
I'm currently using the Api Rest from python i've add my custom report in my application getting a embed token and i've been reading about add filter in my report, but just i've find information about how i can how do with the JavaScript SDK but i dont have information how i can add a filter through the Api Rest , someone could give to me some information about that, How can i add filter to report through the Api Rest i had reading that http://docs.powerbi.apiary.io/# (sorry for my english haha)
Here is the information on adding filters through JavaScript API.
https://github.com/Microsoft/PowerBI-JavaScript/wiki/Filters
2. I want to be able to filter my report even before it loads, ( I am creating an app so my clients can see their data through a Power Bi report, but I want to filter it by their IDs even before it loads, because one client may not see each other data) is it possible to do so?
I'm currently using the Api Rest from python i've add my custom report in my application getting a embed token and i've been reading about add filter in my report, but just i've find information about how i can how do with the JavaScript SDK but i dont have information how i can add a filter through the Api Rest , someone could give to me some information about that, How can i add filter to report through the Api Rest i had reading that http://docs.powerbi.apiary.io/# (sorry for my english haha)
Hi @tenenwurcel
For the first question: The token is generated by the Power BI Api, you just need to configure properly your web config. Follow these steps:
https://powerbi.microsoft.com/en-us/documentation/powerbi-developer-embedding-content
And for the second one you can use this demo code:
<html> <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/jquery/dist/jquery.js"></script> <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/powerbi-client/dist/powerbi.js""></script> <script type="text/javascript"> var embedConfiguration = { type: 'report', accessToken: 'token', embedUrl: 'embedURL' }; var report; window.onload = function () { var $reportContainer = $('#reportContainer'); report= powerbi.embed($reportContainer.get(0), embedConfiguration); var Filter1 = { $schema: "http://powerbi.com/product/schema#advanced", target: { table: "Table1", column: "T1id" }, logicalOperator: "OR", conditions: [ { operator: "Contains", value: "id1" } ] } report.on('loaded', event => { report.getFilters() .then(filters => { filters.push(Filter1); return report.setFilters(filters); }); }); } function reloadreport(){ var $reportContainer = $('#reportContainer'); powerbi.embedNew($reportContainer.get(0), embedConfiguration); }; </script> <div id="reportContainer"></div> </html>
Hope it works for you.
Julian
Hey Juramirez,
First of all thank you so much for the reply.
I think you misunderstood what I meant about the filter.
I don't want to load a new filter pane, I want to be able to filter the report even before it loads, because I want my clients to not see each other data.
So lets say I have a report regarding to 3 clients cli1, cli2 and cli3. So when cli1 is using the web app and load the report I want him to only see the data regarding to cli1 and not be able to see the data regarding to cli2 and cli3.
Is it possible to do so?
Thank so much once again,
Henrique.
Hello,
I am a new user of Power Bi embedded (developing a webapp using javascript sdk) and I have two doubts.
1. Its still not clear how to get the acess token from Azure, should I just make a post request to this (https://api.powerbi.com/v1.0/myorg/groups/{group_Id}/reports/{report_id}/GenerateToken) api?
2. I want to be able to filter the report before it even loads ( I am creating reports for my clients, but I want to filter them by their ID, because one client may not see each others information), is it possible to do so?
Thank you very much.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
13 | |
2 | |
2 | |
1 | |
1 |