The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello everyone,
I am embedding a Power BI report in a web application using the Power BI REST API and JavaScript SDK. My goal is to open multiple instances of the same report at the same time, each with different filters applied at the dataset level.
Even though I apply different filters to the dataset before opening the report, when multiple reports are opened simultaneously, they share the same filter state. This means that applying a filter in one instance affects the others.
This is my embed code:
<!DOCTYPE html>
<html lang='es'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Fabric SandBox</title>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
crossorigin="anonymous"></script>
<script src="powerbi.js"></script>
</head>
<body>
<h2>Fabric Sandbox</h2>
<div id='{{CONTAINER_ID}}' style='width:100%;height:800px;'></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
if (typeof powerbi === 'undefined' || !window.powerbi) {
console.error('❌ Power BI Client SDK no se cargó correctamente.');
return;
}
var models = window['powerbi-client'].models;
var embedConfig = {
type: 'report',
id: '{{REPORT_ID}}',
embedUrl: 'https://app.powerbi.com/reportEmbed?reportId={{REPORT_ID}}&groupId={{WORKSPACE_ID}}',
accessToken: '{{EMBED_TOKEN}}',
tokenType: models.TokenType.Embed,
settings: {
filterPaneEnabled: false,
navContentPaneEnabled: false
}
};
// Agrega el parámetro a la URL de embed
var embedUrl = 'https://app.powerbi.com/reportEmbed?reportId={{REPORT_ID}}&groupId={{WORKSPACE_ID}}&rs:embedsessionid={{UNIQUESESSIONID}}';
embedConfig.embedUrl = embedUrl;
if (report) {
report.destroy().then(function () {
var oldContainer = document.getElementById('{{CONTAINER_ID}}');
oldContainer.parentNode.removeChild(oldContainer);
var newContainer = document.createElement('div');
newContainer.id = '{{CONTAINER_ID}}';
newContainer.style.width = '100%';
newContainer.style.height = '800px';
document.body.appendChild(newContainer);
embedConfig.embedUrl = 'https://app.powerbi.com/reportEmbed?reportId={{REPORT_ID}}&groupId={{WORKSPACE_ID}}&cb=' + new Date().getTime();
report = powerbi.embed(newContainer, embedConfig);
});
}
var reportContainer = document.getElementById('{{CONTAINER_ID}}');
var powerbiService = powerbi
powerbiService.reset(reportContainer);
var report = powerbiService.embed(reportContainer, embedConfig);
});
</script>
</body>
</html>
Any suggestions would be greatly appreciated! 🚀
Thanks 🤗
Solved! Go to Solution.
Hi @Jsola,
Thanks for reaching out to the Microsoft fabric community forum.
I understand that you're trying to open multiple instances of the same Power BI report with different dataset-level filters, but the filters are being shared across instances. This happens because modifying dataset parameters before generating an embed token applies changes at the dataset level, which affects all report instances. You can use Report-Level Filters instead of Dataset Parameters as rather than modifying the dataset, apply report-level filters dynamically using the Power BI JavaScript SDK.
I would also take a moment to thank @Deku, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.
Community Support Team
If this post helps then please mark it as a solution, so that other members find it more quickly.
Thank you.
Hi @Jsola,
Thanks for reaching out to the Microsoft fabric community forum.
I understand that you're trying to open multiple instances of the same Power BI report with different dataset-level filters, but the filters are being shared across instances. This happens because modifying dataset parameters before generating an embed token applies changes at the dataset level, which affects all report instances. You can use Report-Level Filters instead of Dataset Parameters as rather than modifying the dataset, apply report-level filters dynamically using the Power BI JavaScript SDK.
I would also take a moment to thank @Deku, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.
Community Support Team
If this post helps then please mark it as a solution, so that other members find it more quickly.
Thank you.
Hi,
Thanks for your response, @Deku and @v-mdharahman
I’m considering applying RLS (Row-Level Security) in C# before generating the embed token to filter the data. I believe filtering using the Power BI JavaScript SDK is somewhat insecure, as an advanced user could modify the code in the browser and gain access to restricted data.
I’ll give this option a try and let you know how it goes.
Many thanks, and have a great weekend!
This sounds alot like the power bi load test tool. I would look at this repo
User | Count |
---|---|
36 | |
15 | |
11 | |
11 | |
9 |
User | Count |
---|---|
46 | |
44 | |
20 | |
18 | |
18 |