Forum Discussion

Developmentguy's avatar
Developmentguy
Regular Visitor
2 years ago

Export a single visual to pdf using power bi REST api,

Hi,

 

I am looking for a way to export a single visual using power bi REST apis, I am able to export with no filter applied, but I failed when I used filter or bookmark,

below are the filter string I am passing, it gives me export but it ignore the filter, it gives me the old/default report.

 

{
    "format": "pdf",
    "powerBIReportConfiguration": {
        "settings": {
            "includeHiddenPages": false
        },
        "pages": [
            {
                "pageName": "ReportSection",
                "visualName": "56431add05c043688b0c"
            }
        ],
        "reportLevelFilters": [
            {
                "filter": "bi_tbl_resthours_violation/violation_date ge ('2023-05-17T19:00:00.000Z') and 
                               bi_tbl_resthours_violation/violation_date lt ('2023-05-18T19:00:00.000Z')"
            }
        ]
    }
}

 

below are the weired pdf result that received when i applied bookmark,

exported pdf single visual 

 

 

orignal report

 

 

 

 

 

4 Replies

    • Developmentguy's avatar
      Developmentguy
      Regular Visitor

      Hi AmosHersch  there was 1 issue correct syntax is 

       

       

       

      "filter":"bi_tbl_resthours_violation/violation_date ge ('2023-05-17T19:00:00.000Z') and 
                                     violation_date lt ('2023-05-18T19:00:00.000Z')"

       

       

       

      I tried to pass in the following ways but nothing worked

       

       

       

      "filter":"bi_tbl_resthours_violation/violation_date ge ('2023-05-17T19:00:00.000Z') and 
                                     violation_date lt ('2023-05-18T19:00:00.000Z')"
      
      ////////////////
      
      "filter":"bi_tbl_resthours_violation%2Fviolation_date%20ge%20(%272023-05-18T19:00:00.000Z%27)%20and%20violation_date%20lt%20(%272023-05-18T19:00:00.000Z%27)"

       

       

       

      what is wrong,

      I got the response 200 OK, but the export return with (no filter applied result even though I applied the filter)

      also with same filter when i pass as url query in power bi portal it works fine, and return the filtered result.

       

      note that I have multiple visuals in same page and multiple pages in same report, I hope it's not an issue. 

      • AmosHersch's avatar
        AmosHersch
        Microsoft Employee

        If the filter now works as expected in Power BI portal for the selected visual it is expected to work when you export. You don't have to escape the filter string (with %20 instead of space, etc.).

        You can try exporting the entire report/report page with the same filter and see if it applied instead of a single visual.

        I don't have other suggestions besides creating a support ticket with all the details.