Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreThe FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now
Is it possible, with embedded report, to filter content automatically based on the UID logged ito the app which the report is embedded?
@twalsh0625 wrote:
Is it possible, with embedded report, to filter content automatically based on the UID logged ito the app which the report is embedded?
Yes.
If the UID you mean is a Power BI Account, you can use Embedding with Power BI users and set Power BI Row Level Security.
If the UID you mean is the userID in your own app, you'll have to use Embedding with non-Power BI users. As to filter or using RLS, RLS used to work for the old embedding model(deprecated), for the new model, the RLS feature is on the roadmap and would be released in next quarter. So at this moment, use filter in the Power BI Javascript API can be the only workaround. See a demo below.
<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">
window.onload = function () {
var uid= ["uid1"]; //get the uid with javascript from your page
var Filter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "Table",
column: "UID"
},
operator: "Contains",
values: uid
}
// Read embed application token from Model
var accessToken = "H4sIAAAAAAAEAB2 xxxxx uCwAA";
// Read embed URL from Model
var embedUrl = "https://app.powerbi.com/reportEmbed?reportId=1f1d9145-738a-4d20-ab5b-1236b283e942&groupId=73e1a3c6-08c4-4651-aa04-2bb701a573c7";
// Read report Id from Model
var embedReportId = "1f1d9145-738a-4d20-ab5b-1236b283e942";
// Get models. models contains enums that can be used.
var models = window['powerbi-client'].models;
// Embed configuration used to describe the what and how to embed.
// This object is used when calling powerbi.embed.
// This also includes settings and options such as filters.
// You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
var embedConfiguration = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: accessToken,
embedUrl: embedUrl,
id: embedReportId,
permissions: models.Permissions.All,
filters:[Filter,Filter2],
settings: {
filterPaneEnabled: true,
navContentPaneEnabled: true
}
};
var $reportContainer = $('#reportContainer');
var report = powerbi.embed($reportContainer.get(0), embedConfiguration);
}
</script>
<div id="reportContainer" powerbi-settings-nav-content-pane-enabled="true" powerbi-settings-filter-pane-enabled="true"></div>
</html>
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |