Passing Parameters in URL to Filter a Power BI Report

2 Comments

We have the ability to pass filters to Power BI reports so we can contextually filter the data displayed. This is useful when we are integrating Power BI with 3rd party applications and embedding in web pages where we want to show filtered data. Here are the steps to do this.

First, connect to data. We will use the sample Accounts data here, which can be connected to via the Power BI Web connector.

Rename Table 0 to Accounts:

Next, create a report with visualizations. The visualizations will show unfiltered data, i.e. all accounts, all industries etc:

Now, publish the report to the Power BI Service:

We see the report now in the Power BI Service:

Our report URL is: https://app.powerbi.com/groups/me/reports/02ff8888-a5fd-4dc7-c9dabf5ca0a5/ReportSection.

Now let’s add the filters. To do this, we append to our report URL: ?filter=query/field eq ‘data to filter on’

For example, let’s say we want our report to only show data for AccountId 7. Our query would look like:

https://app.powerbi.com/groups/me/reports/02ff8888-a5fd-4dc7-c9dabf5ca0a5/ReportSection?filter=Accounts/AccountId eq 7

We can see the data on the report has changed, and it has picked up the filter:

Or if we wanted to filter by City = ‘Oklahoma City’, we can do:

https://app.powerbi.com/groups/me/reports/02ff8888-a5fd-4dc7-c9dabf5ca0a5/ReportSection?filter=Accounts/City eq ‘Oklahoma City’

As mentioned, this is useful for embedding scenarios. For more information on operators and data types, check out https://docs.microsoft.com/en-us/power-bi/service-url-filters.

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube

 

2 Responses to Passing Parameters in URL to Filter a Power BI Report

Leave a Reply

Your email address will not be published. Required fields are marked *