Forum Discussion
Embedded - Open Same Report Simultaneously with Different Filters in Dataset
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.
How It Works:
- The C# code authenticates with Azure AD, retrieves an access token, and generates an embed token for the report.
- It updates dataset parameters before generating the embed token.
- The HTML/JS file then embeds the report using the Power BI JavaScript SDK, ensuring each instance has a unique session ID.
The Problem:
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.
Questions:
- What am I doing wrong?
- How can I ensure that each report instance keeps its own dataset filters without interfering with the others?
- Is there a way to generate independent dataset snapshots per session?
- Would using separate datasets or duplicate reports be the only workaround?
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 🤗
- Anonymous1 year ago
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 TeamIf this post helps then please mark it as a solution, so that other members find it more quickly.
Thank you.
3 Replies
- AnonymousNot applicable
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 TeamIf this post helps then please mark it as a solution, so that other members find it more quickly.
Thank you.
- JsolaFrequent Visitor
Hi,
Thanks for your response, Deku and Anonymous
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!