Forum Discussion
how to filter the publish to web report using query string filter?
Anonymous& GilbertQ
I understand the official documentation states that passing query string filters in a public URL for Power BI is not supported.
However, how are the URLs below functioning?
I would like to use a similar approach for my requirements. Could you please provide a more detailed explanation of the JavaScript steps involved?
- &Country=France: Link_with_France_Country
- &Country=Italy -> Link with Filtering Italy Country
- &Country=Spain -> Link with Filtering Spain Country
Anonymous
I'm not an expert in JavaScript, but with the help of ChatGPT, I could write the following code. However, I do not see the filter being applied to the report as expected.
Not sure about this URL he is not using the JS approach:
Applying the filter `&Country=France` directly in the URL works for this user. I'm not sure how we can achieve the same result.
https://app.powerbi.com/view?r=eyJrIjoiZTA5N2VkYWQtYmNiMS00YWFmLWEwZWQtOGY4MmExNTlmZjllIiwidCI6ImMyOGQyZTEyLTA5ODgtNGFjZi1iZGJhLTExOTU4MmU4ZDA4ZCIsImMiOjl9&Country=Italy
https://app.powerbi.com/view?r=eyJrIjoiZTA5N2VkYWQtYmNiMS00YWFmLWEwZWQtOGY4MmExNTlmZjllIiwidCI6ImMyOGQyZTEyLTA5ODgtNGFjZi1iZGJhLTExOTU4MmU4ZDA4ZCIsImMiOjl9&Country=Francebelow is my code:
<!DOCTYPE html>
<html>
<body>
<h1>My Power BI Report</h1>
<object
data="https://app.powerbi.com/view?r=eyJrIjoiOGUwZWNmYjktZTc2Zi00MWIzLTk5NzktMjZmMjY3ZDIwMjQyIiwidCI6ImE2OTI0YWVjLTI1N2EtNDkzZi04ZDUyLTM1ZDA1MzdiMTc3NiIsImMiOjZ9&pageName=67c0b6533c0b91c3888e"
width="600"
height="400">
</object>
<script>
// Wait for the page to fully load
document.addEventListener('DOMContentLoaded', function () {
// Find the element with data-row-index="2"
var targetElement = document.querySelector('[data-row-index="2"] .slicerCheckbox');
if (targetElement) {
// Update the aria-selected attribute to "true"
targetElement.closest('.slicerItemContainer').setAttribute('aria-selected', 'true');
// Update the class to include "selected"
targetElement.classList.add('selected');
}
});
</script>
</body>
</html>
- Anonymous1 year agoNot applicable
Hi, automation
You can check out the tutorial below and note that this method is not in the official technical support direction.
URL based navigation for a report shared via 'Publish to Web' - Power of Business Intelligence
You need to decide for yourself whether you need to try it or not. That's all I can help you with so far. If you have any questions about Javascript, you need to consult the developer platform. Seek help with your writing.
I think the following should help you:
Tamper-proof URL parameters with JWTs
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- automation1 year agoFrequent Visitor
Anonymous/ GilbertQ
It seems that no one knows the rationale behind this. From what I gather, the URLs below are working directly with Power BI Embedded Public URLs and are filtering reports using Query String Parameters.
- &Country=France: Link_with_France_Country
- &Country=Italy -> Link with Filtering Italy Country
- &Country=Spain -> Link with Filtering Spain Country
It's really surprising to me that the official documentation differs from the user-implemented version! 😁
- Anonymous1 year agoNot applicable
Hi, automation
Thanks for the feedback! As you said, this feature is really made possible by Power BI Embedded. You don't need to publish the report to the web, just share the link and set URL filters, or control the slicer options by writing a JavaScript script.
If you've already found a solution, feel free to mark your reply or a helpful response as a solution so that other community members can benefit from your experience as well.
Thank you for your cooperation and understanding!
Best Regards
Jianpeng Li
- &Country=France: Link_with_France_Country