cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

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

Accepted Solutions
Highlighted
Helper I
Helper I

Re: Adding filters in Power BI Embedded with PHP and JS

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
Highlighted
Community Support
Community Support

Re: Adding filters in Power BI Embedded with PHP and JS

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.
Highlighted
Helper I
Helper I

Re: Adding filters in Power BI Embedded with PHP and JS

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

Highlighted
Regular Visitor

Re: Adding filters in Power BI Embedded with PHP and JS

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

Helpful resources

Announcements

August Community Highlights

Check out a full recap of the month!

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power BI

Join us for an in-depth look at the new Power BI features and capabilities at the free Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors