Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
84 | |
66 | |
66 | |
48 | |
31 |