Forum Discussion
Export to file - Power BI Report with Filters / Parameters
- Anonymous6 years ago
Hi Anonymous
The documentation currently states that the Bookmark name (whilst accepted as a parameter) is not currently available.
https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exporttofile#pagebookmark
The only way to update output via bookmarks, is to pass in the bookmark state.
And the only way that you can get the bookmark state (that I know of) is via the JavaScript API. https://github.com/Microsoft/PowerBI-JavaScript/wiki/Bookmarks#capture-and-get-a-current-view-as-a-bookmark-object-and-apply-it-back-on-the-current-session
The 'capture' function will return a single string value that represents the bookmark state. You can then pass this into the API.
This is far from ideal... but I think the export API endpoint is still under preview, so will likely change quite a bit.
The idea I raised for adding missing functionality to this API has also moved into the planned phase. So hopefully, it won't be too long before these missing features are available. https://ideas.powerbi.com/ideas/idea/?ideaid=0e056f7d-34b4-4778-974f-929228effcdd
Cheers, Matt
Anonymous
I am using the REST APIs for ExportToFile in my Power Automate flow.
I can export the PDF with no issues in a normal use case, but next I want to try out exporting a PDF with a particular bookmark.
Use case is - I have 5 user groups and I will create 5 bookmarks (one for each).
Will send the PDF in an email to each of them as per their individual bookmarks.
However, when I try to put the bookmark name in my flow, it doesn't work.
Here is how my flow looks -
The error I get is -
Hi Anonymous
The documentation currently states that the Bookmark name (whilst accepted as a parameter) is not currently available.
https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exporttofile#pagebookmark
The only way to update output via bookmarks, is to pass in the bookmark state.
And the only way that you can get the bookmark state (that I know of) is via the JavaScript API. https://github.com/Microsoft/PowerBI-JavaScript/wiki/Bookmarks#capture-and-get-a-current-view-as-a-bookmark-object-and-apply-it-back-on-the-current-session
The 'capture' function will return a single string value that represents the bookmark state. You can then pass this into the API.
This is far from ideal... but I think the export API endpoint is still under preview, so will likely change quite a bit.
The idea I raised for adding missing functionality to this API has also moved into the planned phase. So hopefully, it won't be too long before these missing features are available. https://ideas.powerbi.com/ideas/idea/?ideaid=0e056f7d-34b4-4778-974f-929228effcdd
Cheers, Matt
- orygreg25 years agoAdvocate I
Hi craigbenstock ,
Hope this helps you/somebody. Kept digging and finally have a working copy - this is from a PowerShell script - so it has the double-quotes preceded by a qualifier:
$body = "{ format : `"PDF`",
powerBIReportConfiguration : { reportLevelFilters : [{ filter : `"TableName/FieldName eq 'SomeValue'`" }]} }". . .which looks same/similar to your version.
I used the "Try It" option from the MS documentation page to tweak the body formatting until I got a 20x response code:
https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exporttofileingroup
And here's the page documenting that filtering is possible - it's too bad they don't provide a full, soup-to-nuts working copy that includes a filter example:
https://docs.microsoft.com/en-us/power-bi/developer/embedded/export-to#filters
- Anonymous6 years agoNot applicable
Anonymous
Thanks for providing the details which I didn't know about.
Hoping that this functionality is added soon.
I have voted the idea.
Regards
- craigbenstock5 years agoRegular Visitor
Hi,
I'm posting here because I don't know if there has been an update to the docs since the original post was made.
I also have a requirement where I would like to call "ExportTo" using the REST API from a Javascript AJAX request.
In the docs (https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exporttofile) it says that request body accepts powerBIReportConfiguration which in turn accepts a reportLevelFilters which is of type ExportFilter.
According the docs an ExportFilter is a string in the format as described under the article https://docs.microsoft.com/en-us/power-bi/collaborate-share/service-url-filters e.g.
?filter=Store/Territory eq 'NC'
I've tried various permutations trying to get this to work but I never get a filter applied.
Does anyone know...
- Should this filter actually be working now?
- What format the filter should be
- An example of it in code
Here's an example of an attempt that DOESNT work for reference:var url = "https://api.powerbi.com/v1.0/myorg/reports/" + reportId + "/ExportTo";
$.ajax({
"type": "POST",
"url": url,
"headers": {
"Authorization": "Bearer " + accessToken
},
"data": {
"format": "pdf",
"powerBIReportConfiguration": {
"reportLevelFilters": [{ "filter": "products/ProductName eq 'ExampleProductName'" }]
}
}
})
Cheers,Craig
- AndrewLGoldman5 years agoAdvocate I
I am running into the same issue as craigbenstock but only since December it seems - but it's weird since exporting to .pdf/.pptx seems to work fine in the Power BI Service, just it's no longer capturing filters/bookmark state over API calls - any ideas?
- orygreg25 years agoAdvocate I
Hi craigbenstock - Any chance you've figured this out?? I'm in the same boat - wanting to apply a filter at runtime when exporting the report as PDF. I haven't been able to find a working example.
Thanks, Greg
- DavidSkyles5 years agoNew Member
We went down a similar path. Ultimately, the only solution we found is that the published report CANNOT have any report-level filters applied when published.
- KiranHosakote4 years agoPost Patron
Hi DavidSkyles,
We have a much simpler solution for this often requested feature. We've built a tool called BI Helper https://bihelper.tech/ to automate the generation of PDF / PPTX reports from Power BI (Pro and Premium), with slicers and filters applied. Our implementation bypasses the limitations of the API endpoints.
With BI Helper, you can select report pages to print, schedule and generate multi-page PDF / PPTX reports and email them to your users. BI Helper has an option to include matrix and table visuals as Excel files, and lots of other advanced features. Our users routinely run hundreds of reports of up to 30 pages each, with the process fully automated from report generation to delivery.
BI Helper is simple to configure and use with your Power BI reports and dashboards. It is secure and scalable and offers a 14 day free trial. Try it out and let us know how it works for you.Kiran Hosakote
BI Helper
- KiranHosakote4 years agoPost Patron
Hi orygreg2 and craigbenstock,
If you're still looking, here's a solution.
BI Helper https://bihelper.tech automates the generation of PDF / PPTX reports from Power BI (Pro and Premium), with slicers and filters applied either in batch mode or at runtime. Our implementation bypasses the limitations of the Power BI API endpoints.
In BI Helper, you can select pages to print, schedule and generate multi-page PDF / PPTX reports and email them to your users. Our users routinely run hundreds of reports of up to 30 pages each, with the process fully automated from report generation to email delivery.
Do take a look at https://bihelper.tech and let us know if you need more information.
Kiran Hosakote
BI Helper