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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
artlemaks
Helper II
Helper II

Adding filters in Power BI Embedded with PHP and JS

have a Power BI Embedded service running on my Azure instance. I have successfully embedded the report using CURL PHP and JS. The report loads fine.

I am now trying to add filters to the report. I have tried following an answer here How to set filters in reports power BI embedded javascript but I am getting an error

Uncaught SyntaxError: Missing initializer in const declaration

This is what my JS looks like for the basicFilter

  const basicFilter: pbi.models.IBasicFilter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "storemaster",
column: "customer_id"
},
operator: "In",
values: [<? echo $customer_id; ?>],
filterType: 1 // pbi.models.FilterType.BasicFilter
}

and then when generating the actual report

var embedConfiguration= {
type: 'report',
id: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', // the report ID
embedUrl: "<?php echo $embedUrl; ?>",
accessToken: "<?php echo $token; ?>" ,
filters: [basicFilter]
};

Where am I going wrong? I couldn't find any other answers to that question that would help with my problem.

1 ACCEPTED SOLUTION
artlemaks
Helper II
Helper II

I have contacted Power BI support and they have pointed me to Embedded Playground in order to test my code.

 

While playing around there, I noticed one major difference in my code against Power BI. 

 

I was using 

 

const basicFilter: pbi.models.IBasicFilter = {

While the correct syntax should be

const basicFilter = { 

I have made that change and now my report loads properly.  

View solution in original post

3 REPLIES 3
superxerox
Regular Visitor

How did you achieve Embedded power bi in PHP ?, I have days looking for documentation and I can't. I hope you can help me

artlemaks
Helper II
Helper II

I have contacted Power BI support and they have pointed me to Embedded Playground in order to test my code.

 

While playing around there, I noticed one major difference in my code against Power BI. 

 

I was using 

 

const basicFilter: pbi.models.IBasicFilter = {

While the correct syntax should be

const basicFilter = { 

I have made that change and now my report loads properly.  

v-xuding-msft
Community Support
Community Support

It is weird. Generally, it is caused that we don't specify a value for a const declaration while encountering the error:  Uncaught SyntaxError: Missing initializer in const declaration.  But I check your code. It should work. 

 

Please create a support ticket to get the dedicated support.

Support Ticket.gif

Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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