Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I'm applying custom filters for power bi report using some javascript code. but filters are not applying . Im getting powerbi report on browser without any filter.
I'm following Javascript code here :
below one is sample code which iam using .
<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 models = window['powerbi-client'].models;
const basicFilter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "TableName",
column: "ColumnName"
},
operator: "In",
values: ["Jr.Software"],
filterType: models.FilterType.Basic,
requireSingleSelection: true
}
var embedConfiguration = {
type: 'report',
tokenType: models.TokenType.Embed,
id: reportId,
accessToken: '{myToken}',
embedUrl: 'https://app.powerbi.com/view?{-------}&pageName=ReportSection',
permissions: models.Permissions.All,
filters:[basicFilter],
settings: {
filterPaneEnabled: true,
navContentPaneEnabled: true
}
};
var $reportContainer = $('#reportContainer');
var report = powerbi.embed($reportContainer.get(0), embedConfiguration);
report.updateFilters(models.FiltersOperations.Add,[basicFilter])
}
</script>
<div id="reportContainer"></div>
i need render power bi report with filters below like:
pls can anyone suggest where i have done mistake in above javascript code .
could you please provide any links .
thanks
Goutham pamula
Solved! Go to Solution.
Hi @GouthamPamula ,
You can refer the following links to get it:
Addling filter using javascript API (Power BI Service)
Embed your Power BI report with predefined filters
const filter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "DimProduct",
column: "ColorName"
},
operator: "In",
values: ["Silver"]
};
var config = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: accessToken,
embedUrl: embedUrl,
id: embedReportId,
permissions: models.Permissions.All,
settings: {
filterPaneEnabled: true,
navContentPaneEnabled: true
}
};
// Embed the report and display it within the div container.
var report = powerbi.embed(reportContainer, config);
report.on('loaded', event => {
report.getFilters()
.then(filters => {
filters.push(filter);
return report.setFilters(filters);
});
Best Regards
Hi @GouthamPamula ,
You can refer the following links to get it:
Addling filter using javascript API (Power BI Service)
Embed your Power BI report with predefined filters
const filter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "DimProduct",
column: "ColorName"
},
operator: "In",
values: ["Silver"]
};
var config = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: accessToken,
embedUrl: embedUrl,
id: embedReportId,
permissions: models.Permissions.All,
settings: {
filterPaneEnabled: true,
navContentPaneEnabled: true
}
};
// Embed the report and display it within the div container.
var report = powerbi.embed(reportContainer, config);
report.on('loaded', event => {
report.getFilters()
.then(filters => {
filters.push(filter);
return report.setFilters(filters);
});
Best Regards
Thank you for sharing the information
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
9 | |
7 | |
2 | |
2 | |
2 |
User | Count |
---|---|
6 | |
5 | |
4 | |
4 | |
4 |