Filter a Power BI tile on your web page

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: http://moraschi.com/2015/12/08/embed-multiple-power-bi-tiles-into-your-web/, and http://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!

    • KW
    • June 23, 2017
    Reply

    Hi there, I still can get the filtered url to work on a single field (I’m filtering a report)
    This is the code I’m using:

    • Alvin Ong
    • April 22, 2016
    Reply

    Hi Davide,
    By any chance, have you tried using multiple filters coming from different tables? The filter works where the last $ is read but disregards the other condition.

    I use this syntax for a single filter: https://app.powerbi.com/reportEmbed?reportId=a1v2b&$filter=TABLENAME/COLUMNNAME eq ‘FIELDVALUE‘

    Thanks.

      • KW
      • June 23, 2017
      Reply

      Hi there, I’m using the same syntax embedded in an iframe but it doesnt work..
      Did you manage to get it work in an iframe?
      My code is

    • Reply

      HI Alvin, very good question. I did not try multiple filters: don’t know how it would work. But as a hint I’d review the oData Filter System Query Option ($filter) documentation on the web. You may find the syntax of the AND/OR operators… let me know how it works,
      Davide

    • Ben
    • April 7, 2016
    Reply

    Hi Davide,
    Where is the Filter placed in the report, at the Visual Level, Page Level, Report level or somewhere else ? or no filter at all ?

    thank you

    • Ben
    • April 7, 2016
    Reply

    Hi Davide,
    Where is the Filter placed in the report, at the Visual Level, Page Level, Report level or somewhere else ? or no filter at all ?

    thank you

    • Reply

      Actually in the example I’m filtering a tile, not a report. But to answer your question: I would put no filter at all in the report. Only in the embed url
      regards

    • Joe
    • April 6, 2016
    Reply

    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.

    • Reply

      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 (‘)?

        • Joe
        • April 6, 2016
        Reply

        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.

    • Ryan
    • March 21, 2016
    Reply

    The filters don’t seem to work with tiles anymore, but do work with reports

    • Reply

      Hi Ryan, thanks for the comment. I will look at the code.

      • Reply

        There was an error due to a wrong token, now it is fixed and should be working fine. thanks again for pointing this out.

    • Ryan
    • March 21, 2016
    Reply

    I can’t get this to work with tiles, but only reports…

  1. Reply

    HI Alvin, very good question. I did not try multiple filters: don’t know how it would work. But as a hint I’d review the oData Filter System Query Option ($filter) documentation on the web. You may find the syntax of the AND/OR operators… let me know how it works,
    Davide

Leave a Reply

15 thoughts on “Filter a Power BI tile on your web page

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

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

  2. Hi Davide,
    Where is the Filter placed in the report, at the Visual Level, Page Level, Report level or somewhere else ? or no filter at all ?

    thank you

  3. Hi Davide,
    Where is the Filter placed in the report, at the Visual Level, Page Level, Report level or somewhere else ? or no filter at all ?

    thank you

    1. Hi there, I’m using the same syntax embedded in an iframe but it doesnt work..
      Did you manage to get it work in an iframe?
      My code is

  4. Hi there, I still can get the filtered url to work on a single field (I’m filtering a report)
    This is the code I’m using:

Leave a Reply