Filter a Power BI tile on your web page
EDIT 2016-07-12: Microsoft has changed their API and policies and functionality, so this artcile is obsolete now. I will shut down the sample site. For details, please see: https://powerbi.microsoft.com/en-us/blog/what-s-new-and-what-s-next-for-power-bi-embedded-july-2016/
======================================================================================================================
I received a lot of feedback regarding my two recent posts: https://moraschi.com/2015/12/08/embed-multiple-power-bi-tiles-into-your-web/, and https://moraschi.com/2015/11/30/use-a-power-bi-tile-in-your-web-page/
So I decided to continue in my exploration of the Power BI API. The next natural step in creating customized dashboards is the ability to dynamically filter the tiles based on user interaction. As of today, this is something you cannot achieve in https://app.powerbi.com (you can only filter using selectors in Reports).
There is a post here, with very scarce information about a parameter of the embed API, namely $filter. We can use this parameter much like its oData cousin, with the same syntax.
&$filter={tablename/fieldname}+eq+'{literal constant}’
I tested it for string parameters and it works. Did not have such luck with dates. Everything will eventually come into place, as this API is still under development as I understand.
I created a sample web page trying to keep it very simple, to demonstrate how this works. You can find it here and you are welcome to help yourself reusing my code and adapting it to your needs. In the example you will see a list box, clicking on it will trigger a refresh of the tile with the appropriate results.
Happy coding!
I can’t get this to work with tiles, but only reports…
The filters don’t seem to work with tiles anymore, but do work with reports
Hi Ryan, thanks for the comment. I will look at the code.
There was an error due to a wrong token, now it is fixed and should be working fine. thanks again for pointing this out.
Hey Davide, sorry for my ignorance, but I am trying to achieve a similar report filtering as what you have shown.. If my result is currently just the base report without any filtering, do you think that indicates that my embed URL syntax is wrong? Or is there something i possibly need to set up inside the BI report to enable filtering via these URL’s? the syntax i have is https://app.powerbi.com/reportEmbed?reportId=A&$filter=B/C+eq+'D‘ where A = report, B = Table, C = field, D = value.
Hi Joe, in my example I’m filtering a tile, not a report. I never tried it, but your syntax looks OK to me. Maybe you need to escape the single quote (‘)?
Thanks for the Tip Davide! Doesnt seem to be a syntax problem, i will research what may be set up incorrectly within our Report guy’s power BI setup.