Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
Developmentguy
Regular Visitor

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 

Developmentguy_0-1701325612935.png

 

 

orignal report

Developmentguy_1-1701325797941.png

 

 

 

 

 

4 REPLIES 4
AmosHersch
Microsoft Employee
Microsoft Employee

@Developmentguy Did you test your filter by opening the same report in Power BI portal and adding it to the URL as a query parameter as described here Filter a report using query string parameters in the URL - Power BI | Microsoft Learn?

It can help understand if the issue happens because of the filter itself or for a different reason

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. 

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.

Ok thank you,

I just wanted to make sure if it is possible, because I saw couple of guys mentioned that filter works if you have single visual in a page, or put single visual in a page and try to export with filter, also on a video published by microsoft on youtube shows single visual in a page.

https://www.youtube.com/watch?v=ybWWTVt_guA

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.