Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
I am working through setting up an export to pdf button for power bi embedded. I have the initial export working where it will export the report in question. However, if I click on a slicer or filter within a visual I am unable to export the filter used so I can then export the filtered report to pdf for the end users.
So how can I get the filters a user has clicked on so that I can export that information?
Below is whatI have so far.
public async Task<string> PostExportRequest(
Guid reportId,
Guid groupId,
FileFormat format,
IList<string> pageNames = null, /* Get the page names from the GetPages REST API */
string urlFilter = null)
{
var client = GetPowerBiClient();
var userName =WebHelper.GetCompanyID();
var report = client.Reports.GetReportAsync(groupId, reportId).Result;
// Get the filters from the report
var reportTest = await client.Reports.GetReportInGroupAsync(groupId, reportId); //placed these here to see if there were any values that exported report filters
var reportTestAgain = client.Reports.GetReportAsync(groupId, reportId); //placed these here to see if there were any values that exported report filters
var reportName = report.Name;
string ExportFilter = "";
var powerBIReportExportConfiguration = new PowerBIReportExportConfiguration
{
Identities = new List<EffectiveIdentity>
{
new EffectiveIdentity
{
Username = userName.ToString(),
Roles =new List<string> { "RLS_ROLE" },
Datasets = new List<string> { report.DatasetId }
}
},
Settings = new ExportReportSettings
{
Locale = "en-us"
},
// Note that page names differ from the page display names
// To get the page names use the GetPages REST API
//Pages = pageNames?.Select(pn => new ExportReportPage(Name = pn)).ToList(),
//Pages = pageNames?.Select(pn => new ExportReportPage { PageName = "ReportSectionbb06cfc5609070ee41ea" }).ToList(),
// ReportLevelFilters collection needs to be instantiated explicitly
ReportLevelFilters = !string.IsNullOrEmpty(urlFilter) ? new List<ExportFilter>() { new ExportFilter(urlFilter) } : null //no url filter comes through, I do not see any ?filter in the URLs
};
var exportRequest = new ExportReportRequest
{
Format = format,
PowerBIReportConfiguration = powerBIReportExportConfiguration
};
if (ExportFilter != "")
{
exportRequest.PowerBIReportConfiguration.ReportLevelFilters =
new List<ExportFilter>() {
new ExportFilter { Filter = ExportFilter }
};
}
Solved! Go to Solution.
HI @Don-Bot,
Did you mean the filters that applied on the 'read view' mode instead of saved to your report?
AFAIK, current the export file API only check saved filters. The 'read view' mode operations did not really apply to the report side so they can't be recognized and traced by rest API.
Regards,
Xiaoxin Sheng
HI @Don-Bot,
Did you mean the filters that applied on the 'read view' mode instead of saved to your report?
AFAIK, current the export file API only check saved filters. The 'read view' mode operations did not really apply to the report side so they can't be recognized and traced by rest API.
Regards,
Xiaoxin Sheng
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
8 | |
6 | |
3 | |
3 | |
2 |