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.
I 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.
Solved! Go to Solution.
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.
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
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.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.