Passing filters to Power BI reports using the URL / query string
02 Dec 2016It was only recently that I discovered this – you can pass filters to Power BI reports by deep linking to it and adding a filter in the URL (also called query string). I am not even sure this is a feature, since it only seems to work for 'equals' and does not work on Dashboards in Power BI.
First of all, we need to understand deep linking in Power BI. Most artifacts in Power BI (for example reports and dashboards) have a their own URL. This means we can open them directly when we know the URL. The URL will have the following format:
https://[tenant].powerbi.com/groups/[workspace]/[artifact type]/[artifact id]/[optional part to be opened]
Thus, the URL may look like this:
https://app.powerbi.com/groups/me/reports/dc121d4b-9aad-4494-b1de-8037f53d8355/ReportSection3
This would open page ReportSection3 in report with id dc121d4b-9aad-4494-b1de-8037f53d8355 in my personal workspace in the tenant app.
If you know anything about web development, you know that you can pass things through the URL to the application this is normally done by adding a question mark to the end of the URL and specifying whatever you want to pass. Multiple items can be added by separating them out by ampersands, like this:
https://myurl.com/?firstname=Jeroen&Lastname=ter%20Heerdt
(notice the %20, which is a URL encoded space).
Combining these two things, you can pass parameters to Power BI reports if you have the report URL (simply open the report to get that). Once you have it, add the following:
?filter=[tablename]/[columnname] eq '[filter value]'
So, if I wanted to filter the activity column in my workitem table so it only shows items where the activity is blogging, I would add the following:
?filter=workitem/activity eq 'blogging'
(eq is short for equals here).
This needs, however, to be encoded for the URL. You can easily find tools online to do that for you, or if you know a little bit about what you are doing, you can do it by yourself. The addition above becomes:
?filter=workitem%252Factivity%20eq%20%27blogging%27
(/ becomes %252F, space becomes %20 and ' becomes %27)
This would open page ReportSection3 in report with id dc121d4b-9aad-4494-b1de-8037f53d8355 in my personal workspace in the tenant app with a filter set on the workitem table's activity column to be equal to blogging:
https://app.powerbi.com/groups/me/reports/dc121d4b-9aad-4494-b1de-8037f53d8355/ReportSection3?filter=workitem%252Factivity%20eq%20%27blogging%27
By the way, you would probably only want to use this is very specific scenario's. It is way better to look at Power BI Embedded to integrate Power BI in your applications. Note that Power BI Embedded is targeted at organizations providing software to others (hosted or not). It is not for internal applications.