Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
automation
Frequent Visitor

how to filter the publish to web report using query string filter?

Hello Experts,

 

 

I've gone through this post: Link

 

I am not sure how this filter works on a publish-to-web URL with a query string for

 

How are these country filters working on publishing to web links?

How can I achieve this?

 

 

 

It's mentioned in the official documentation that:

Query string filtering doesn't work with Publish to web

 

 

automation_0-1732040658647.png

 

How can a user achieve query string parameter report filters using the "Publish to Web" URL?

Can someone explain how the above URLs function with the Country filter included in the URL? How can I implement this functionality?

 

I have the same requirements for my clients. Could you please guide me on how I can achieve this?

My client is not willing to invest in purchasing an embedding license. We plan to use a single Power BI Pro license and leverage the filter options demonstrated in the URLs above, which include filters for three different countries.

9 REPLIES 9
IsmaelMM
Regular Visitor

A little late, but i was able to do it using this custom visual, it has some limitations but in summary it takes the url and uses the filter api to filter the data.


For example:
&Columns Is 'SomeValue'

https://github.com/orihuela-iom/powerbi-public-query-parameters

automation
Frequent Visitor

@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?

 

 

@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=France

below 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>

 

 

Anonymous
Not 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.

@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.

 

It's really surprising to me that the official documentation differs from the user-implemented version! 😁

Anonymous
Not 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

I haven't found the solution that has been implemented below.

Anonymous
Not applicable

Hi, @automation 

As you mentioned, the idea of implementing post-"publish to web" slicer filtering via JavaScript is very clear. Here are the brief steps to achieve it:

1. First, publish the report on the web.

vjianpengmsft_7-1732069521789.png

 

2. Open the developer tools in your browser, which can usually be opened by right-clicking on the page and selecting "Inspect" or pressing F12.

3. In the console, you can find the HTML tag of the slicer, usually the slicerItemContainer.

vjianpengmsft_8-1732069566622.png

 

4. Achieve the selected state by controlling the aria-selected attribute. You can get that tag using the getElementsByClassName method in JavaScript.

Document: getElementsByClassName() method - Web APIs | MDN

5. Use the setAttribute method to set the value of the aria-selected attribute to implement the filtering function of the slicer.

Element: setAttribute() method - Web APIs | MDN

This approach is beyond the scope of Power BI support. You should implement this according to your development department.

 

 

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.

Anonymous
Not applicable

Hi, @automation 

First of all, thank you for your question! Regarding the URL filter you mentioned, its working principle is to pass the query parameters to the filter panel to achieve report filtering. The specific format is as follows:

 

reportId=xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx&pageName=ReportSection&filter=Table/Field eq 'value'

 

reportId: Identify your report.
pageName: Specify a page in the report.
Table/Field: Correspond to your table name and field name respectively.

Ultimately, this URL will pass the value to the field in the specified table, forming a page filter. As shown in the figure below, I have disassembled it:

vjianpengmsft_0-1732067958829.png

Next, as to why "Publish to Web" does not have this function: when we publish the report to the Web, the report ID and page will be encrypted and converted, and the published report does not have a filter panel, so these values ​​​​cannot be passed to the corresponding fields.

vjianpengmsft_1-1732068128253.png

You mentioned that you have a Pro license and your users are covered by Pro per user licenses. Actually, you don't need to publish the report to the web, you can implement report filtering by simply adding the following suffix to the report URL:

 

?filter=TableName/ColumnName eq 'value'

 

The example is shown in the following figure:

vjianpengmsft_4-1732068509781.png

 

vjianpengmsft_5-1732068628896.png

Here are the results:

vjianpengmsft_6-1732068669552.png

In your case, just replace it with the corresponding country table/field. Finally, you should apply it directly behind the link to your Power BI report instead of publishing it to the web, which not only creates security issues, but also leaves a lot of functionality unsupported.

 

 

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.

 

 

 

 

 

 

GilbertQ
Super User
Super User

Hi @automation 

 

As you have mentioned in your question, query string thought print is not available in publish to web, and there is no work around for this. Unfortunately, you will either have to use power BI embedded or get power BI licensing. If you are looking to use the very string filtering in the url.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.