Forum Discussion
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
- AmosHerschMicrosoft 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
- DevelopmentguyRegular 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.
- AmosHerschMicrosoft 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.