Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
I'm a beginner in Power BI and wrote a code for a taskbar. This taskbar is supposed to be linked to the charts on my dashboard, but that’s not happening. How can I resolve this so that the rendered HTML is directly connected to the Power BI filtering mechanism?
Segue o código:
Solved! Go to Solution.
Hi @alicya-abdala ,
Your code looks like you're trying to build a custom taskbar in Power BI with dynamic content that filters the data based on user selection. However, the issue you're describing is that the HTML rendered doesn't directly integrate with Power BI's filtering mechanism. This means the HTML you're generating is not actually connected to Power BI's built-in filtering system (which happens via the Power BI visuals and slicers).
Power BI and Custom HTML
Power BI itself doesn’t directly allow custom HTML elements to interact with its filtering mechanism unless you use the Power BI API, or Power BI embedded features. What you're trying to achieve with ApplyFilter and ApplyChanges won’t automatically affect the Power BI visuals unless they’re connected to the Power BI filtering system.
Using DAX to Pass Data
Instead of relying on HTML elements to trigger filters, you could use DAX and slicers to control the filters.
You can create a slicer for each of the categories (Data, Ponto, Parâmetro) in Power BI itself.
Modify HTML/JavaScript to Trigger Power BI Filters
// Assuming you have your Power BI embed object in a variable called `report` function applyPowerBIFilter(category, value) { const filter = { $schema : "http://powerbi.com/product/schema#basic",
target : { table : 'DADOS',
column : category },
operator : "In",
values
: [value] };
report.setFilters([filter]).then(
function() { console.log("Filter applied!");
}
).catch(
function(error) { console.error("Error applying filter:", error);
}
);
}
Please mark this as solution if it helps you. Appreciate Kudos.
Hi @alicya-abdala ,
Your code looks like you're trying to build a custom taskbar in Power BI with dynamic content that filters the data based on user selection. However, the issue you're describing is that the HTML rendered doesn't directly integrate with Power BI's filtering mechanism. This means the HTML you're generating is not actually connected to Power BI's built-in filtering system (which happens via the Power BI visuals and slicers).
Power BI and Custom HTML
Power BI itself doesn’t directly allow custom HTML elements to interact with its filtering mechanism unless you use the Power BI API, or Power BI embedded features. What you're trying to achieve with ApplyFilter and ApplyChanges won’t automatically affect the Power BI visuals unless they’re connected to the Power BI filtering system.
Using DAX to Pass Data
Instead of relying on HTML elements to trigger filters, you could use DAX and slicers to control the filters.
You can create a slicer for each of the categories (Data, Ponto, Parâmetro) in Power BI itself.
Modify HTML/JavaScript to Trigger Power BI Filters
// Assuming you have your Power BI embed object in a variable called `report` function applyPowerBIFilter(category, value) { const filter = { $schema : "http://powerbi.com/product/schema#basic",
target : { table : 'DADOS',
column : category },
operator : "In",
values
: [value] };
report.setFilters([filter]).then(
function() { console.log("Filter applied!");
}
).catch(
function(error) { console.error("Error applying filter:", error);
}
);
}
Please mark this as solution if it helps you. Appreciate Kudos.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 56 | |
| 40 | |
| 36 | |
| 20 | |
| 18 |
| User | Count |
|---|---|
| 73 | |
| 73 | |
| 38 | |
| 35 | |
| 26 |