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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Don-Bot
Helper V
Helper V

How do I export a report filter using C# XMLA Endpoint for Power BI Embedded?

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 }
          };
    }

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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

View solution in original post

1 REPLY 1
Anonymous
Not applicable

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

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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