Forum Discussion

SMutlow's avatar
SMutlow
New Member
10 years ago

Passing a filter to an iFrame

HI there.

 

I have been tasked with testing the integration of Power BI with a Web App we are developing.

Using the code on github:
https://github.com/PowerBI/Integrate-a-tile-into-an-app

I have a SQL data source attached to a report in Power BI.

I need to filter the report at run time based on one of the columns and following the example here:
http://blogs.msdn.com/b/powerbidev/archive/2015/09/23/power-bi-api-updates-roundup.aspx

Specifically the example code:

https://app.powerbi.com/embed?dashboardId=c2411ca0-f4fc-4b6f-b2f1-02f62281290d&tileId=9a6b1f88-08b6-47c4-986d-d185b9fa9fbb}&$filter={FieldName} eq '{FieldValue}'

In your example above there is a curly bracket "}" just before "&$filter", I expect this is a typo?

The report is retrieved but the filter has not been applied.


As my column is an int I have tried:

iframe.src=embedTileUrl + "&$filter=tblDataSnapshot/StoreId eq " + storeId + "&width=" + width + "&height=" + height;

and

iframe.src=embedTileUrl + "&$filter=tblDataSnapshot/StoreId eq '" + storeId + "'&width=" + width + "&height=" + height;

Ive tried putting the filter both before and after the height and width code, removing the height and width code.

Ive tried &filter, &$filter and a 100 other variations of OData combinations.

 

Can I get some clarification on the correct syntax please?

10 Replies

    • SMutlow's avatar
      SMutlow
      New Member

       

       

      davidem Thanks very much for the helpful example. I'm almost sure this is the solution.

      However I cannot as yet get it working, I suspect it is because I am using a free account to test with.

      I am only able to see the dashboard I created back in October last year, new reports also are not showing when I use the latest code example project here (PowerBI-CSharp-master\samples\webforms\embed-a-tile-into-an-app): https://github.com/Microsoft/PowerBI-CSharp

       

      davidem the account you are using in that example is a free or pro account?

      • davidem's avatar
        davidem
        New Member

        SMutlow thanks. I also had problems with the CSharp code. I don't recall but I think it was related to the access token not being created properly. See also my articles about OAuth from a bash script to get some hints. Or this preview feature that may also be useful https://moraschi.com/2016/02/05/power-bi-publish-to-web-now-in-preview/

         

        best regards

        Davide

         

        BTW I'm with a Pro account, but should not make difference, the APIs work just the same

  • rishab1992's avatar
    rishab1992
    Regular Visitor

    Is there a way to pass multiple filters for a tile. We are able to filter the data using one filter only and when we tried to pass multiple filters it didn't work. There should be a way to pass multiple filters to an embedded tile

    • swathiOnteddu's avatar
      swathiOnteddu
      New Member

       

      Hi,

       

      I have also tried with <iframe width="800" height="600" src="https://app.powerbi.com/view?r=ReportURL"+"&filter=Tablename/columnname eq 'Value'" frameborder="0" allowFullScreen="true"></iframe>

       

      but it's not working. how to solve this issue.

       

      My requirement is "I have published all user's dashboard via publish to web in power bi. and published URL implemented in html page via IFRAME.

      Now I wants to get specific user dashboard . How it is possible."

       

       

      Thanks in Advance......

      • hjameelq's avatar
        hjameelq
        Advocate IV

        I really tried to make this filter work, but it didn't work so is there a way to pass any filter outside the power BI service world. 

         

        <iframe width="1000" height="2000" src="https://app.powerbi.com/view?r=eyTBjMTlkNyIsImMiOjF9&filter=main/cityname eq 'Aleppo'" frameborder="0" allowFullScreen="true"></iframe>

         

        Not sure if query string feature is enabled with the embededd URLs.