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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
sierra710
Frequent Visitor

Filter Query String Parameter in custom Javascript Embed application

I am looking to build an app that passes a filter query string to a report, similar in format as the filter query string in PBI Service reports:

 

URL?filter=Table/Field eq 'value'

 

then convert this format to Javascript, IBasicFilter

 

const basicFilter: pbi.models.IBasicFilter = {
  $schema: "http://powerbi.com/product/schema#basic",
  target: {
    table: "Store",
    column: "Count"
  },
  operator: "In",
  values: [1,2,3,4],
  filterType: pbi.models.FilterType.BasicFilter
}

 

Curious if anyone has done this before, and knows of a plugin or easier way to transform this structure.  thanks

2 REPLIES 2
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @sierra710,

 

You almost get it done. Please try the online demo here.  You also can get the source code here.

// Build the filter you want to use. For more information, See Constructing
// Filters in https://github.com/Microsoft/PowerBI-JavaScript/wiki/Filters.
const filter = {
  $schema: "http://powerbi.com/product/schema#basic",
  target: {
    table: "Store",
    column: "Chain"
  },
  operator: "In",
  values: ["Lindseys"]
};

// Get a reference to the embedded report HTML element
var embedContainer = $('#embedContainer')[0];

// Get a reference to the embedded report.
report = powerbi.get(embedContainer);

// Set the filter for the report.
// Pay attention that setFilters receives an array.
report.setFilters([filter])
    .catch(function (errors) {
        Log.log(errors);
    });

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks, but this does not address my question. 

 

i am looking to programmatically generate the basic filter, not hard code values.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.