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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors