Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
GouthamPamula
New Member

apply filters to power bi report using power bi javascript api

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 :

 

filterreport02.PNG

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:
repr01.PNG

 

pls can anyone suggest where i have done mistake in above javascript code .
could you please provide any links .

 

thanks 
Goutham pamula

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @GouthamPamula ,

You can refer the following links to get it:

Control report filters

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @GouthamPamula ,

You can refer the following links to get it:

Control report filters

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

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors