Powerbi embedded - Export to pdf with slicers/filters applied

Viewed 677

I'm trying to implement the "Export to PDF" functionality for my Power BI reports embedded (https://docs.microsoft.com/en-us/power-bi/developer/embedded/export-to). The process explained in the docs is pretty clear, but I have only one doubt that has not been addressed: how we need to pass the slicers/filters applied in order to have the current report view as PDF file? I mean, suppose that I have a report with a custom slicers applied with a certain value in a certain time, for example to view all data related to the Germany country, how we can pass this slicer? It must be converted in ODATA query string? I think it's pretty uncomfortable because from the JavaScript API it would mean that we need to retrieve all the state of all the slicer objects in a report and convert them into ODATA query string, managing also particular case (slicer not applied to specific visual and other cases...) is not a simple job. Are there any alternatives?

1 Answers

Query String filtering doesn't work with Publish to web or Export to PDF. But You can capture the filters in bookmark and then export the report to pdf with the filters or slicers you applies.

// Capture the Bookmark state 
const capturedBookmark = await report.bookmarksManager.capture();

The captured state (which is just a string) is then passed to the PowerBI .NET SDK method ExportToFileInGroupAsync as part of the PowerBIReportExportConfiguration that is necessary.

References:

https://docs.microsoft.com/power-bi/developer/embedded/export-to

https://docs.microsoft.com/power-bi/collaborate-share/service-url-filters

https://docs.microsoft.com/javascript/api/overview/powerbi/report-bookmarks

Related