Forum Discussion
Doubt about embed token and filtering.
- 8 years ago
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);
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.