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.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
2 | |
1 | |
1 | |
1 |
User | Count |
---|---|
24 | |
3 | |
2 | |
2 | |
2 |