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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MattCalderwood
Responsive Resident
Responsive Resident

Export to file - Power BI Report with Filters / Parameters

HI All,

I am looking at the new (currently in preview) API for exporting Power BI reports as images/pdf files.
https://docs.microsoft.com/en-us/rest/api/power-bi/reports/exporttofileingroup 

There currently isn't a way to specify Filter/Slicer values for Power BI Reports!
This feels like a big omission to me, especially considering the inclusion of Bookmark capabilities.

Is there a published roadmap for this API endpoint anywhere AND/OR does anyone know if we can expect to see filter options anytime soon?

The API is unusable for many scenarios without this.
I am keeping my fingers crossed that it arrives soon.

Cheers,
Matt

1 ACCEPTED SOLUTION

Hi @vmakhija 

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-b... 

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

View solution in original post

25 REPLIES 25

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?

@MattCalderwood 

Thanks for providing the details which I didn't know about.

 

Hoping that this functionality is added soon.

 

I have voted the idea.

 

Regards

Yeah, thanks Matt. I abandoned the bookmark path - too manual.

EDIT - I've now got it working with Identities and Roles. I can now export a report for every value of a filter.

In case this helps anyone else, here's my simple use case....

I want to create a report for every value of a filter called Country. Because filters aren't yet supported by the ExportTo API, I've used Roles instead.

I created a Role in Power BI Desktop called Country. The filter for this Role is on a table called countries, with a filter expression, [country_code] = username().  The countries table is already setup in my Model with the relevant relationships, and with cross filter direction = single. I then republished my report.

To get the ExportTo working for a specific country, I pass a country code through as the username in the body of the ExportTo API call:

 

{ "format":"PNG",
"powerBIReportConfiguration":
{ "identities": [
{ "username": "AUS",
"roles": [ "Country"],
"datasets": [ "XXXXXXXXXXXXXXX etc" ]
} ] } }

 

In my server-side code, all I need to do is call the ExportTo API in a loop, replacing the username in the body of the call with each country code.

Hi @MattCalderwood 

 

Yeah, I see that bookmarks is a workaround, albeit a poor one. The whole point of using the Export endpoint is to automate. And creating bookmarks is a manual process.

 

I'm very very new to Power BI so I can't get my head around this yet, but this article hints at being able to fudge Roles (handing in a fake user ID as a query string parameter when the access token is requested?) and using a permissions table to drive Row Level Security. So, to use the Export endpoint to produce a sales report for, let's say, a given product, I'm wondering if I could hand in a product code as the fake user ID and then... (I'm not sure what happens then 🙂 ).

 

 

MattCalderwood
Responsive Resident
Responsive Resident

I am struggling to find any details of 'future changes' or roadmap details for this API, so I created an idea for the inclusion of filter parameters.

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/40060261-add-filter-options-to-th...

If you think that this functionality is missing - please go and upvote!
Thanks.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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