Forum Discussion

DavideBono97's avatar
DavideBono97
Helper I
11 months ago
Solved

ExportTo PowerBI - Api ExportTo

I'm using PowerBI's ExportTo API. The report filters seem to be ignored.

I tried like this

 

https://api.powerbi.com/v1.0/myorg/groups/xxxx/reports/xxxx/ExportTo
{
  "format": "PDF",
  "powerBIReportConfiguration": {
    "reportLevelFilters": [
      {
        "filter": "Calendario documento/Documento - Anni trascorsi da ultimo reload lt '5'"
      }
    ],
    "datasetToBind": "xxx",
    "identities": [
      {
        "username": "0_0_0_0",
        "roles": [ "NORLS" ],
        "datasets": [ "xxxx" ]
      }
    ]
  }
}

 

So the API returns 200 but the filter seems to be ignored.

I've already tried these syntaxes but nothing works. Any ideas?

 

'Calendario documento'[Documento - Anni trascorsi da ultimo reload] eq 5

[Calendario documento]/[Documento - Anni trascorsi da ultimo reload] eq 5

[Calendario documento]/[Documento - Anni trascorsi da ultimo reload] eq '5'

Calendario documento/Documento - Anni trascorsi da ultimo reload eq '5'

 

Thanks in advance

  • AmosHersch's avatar
    AmosHersch
    11 months ago

    I did a test with spaces in the table name and column name:

    Table name:          ex1 renamed

    Column name:      Column three 

     

    This requeust body produced a filtered result:

     


    Reqused body:
    {
      "format": "PDF",
      "powerBIReportConfiguration": {
        "settings": {},
        "reportLevelFilters": [
          {
            "filter": "ex1_x0020_renamed/Column_x0020_three lt 0"
          }
        ]
      }
    }

15 Replies

  • v-sshirivolu's avatar
    v-sshirivolu
    Community Support

    Hi DavideBono97 ,
    Thanks for reaching out to Microsoft Fabric Community Forum.

    Try this Solution

    Please use the correct asynchronous export flow:

    Step 1 – Start Export

    POST https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/reports/{reportId}/ExportTo
    Returns an exportId.

    Step 2 – Poll Export Status

    GET https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/reports/{reportId}/exports/{exportId}
    Do not use /status. Poll until "Succeeded" or "Failed".

    Step 3 – Download File

    GET https://api.powerbi.com/v1.0/myorg/groups/{workspaceId}/reports/{reportId}/exports/{exportId}/file

    Example Flow

    Start export - get exportId = abc123

    Poll: GET …/exports/abc123 → returns "Succeeded"

    Download: GET …/exports/abc123/file
    Reference :
    https://learn.microsoft.com/en-us/power-bi/developer/embedded/export-to


    Best Regards,
    Sreeteja.

  • Hi v-sshirivolu 
    I've already tried this way
    But I get this error : 
    {
    "error": {
    "code": "InvalidRequest",
    "message": "Export report filter with empty string provided"
    }
    }

    • v-sshirivolu's avatar
      v-sshirivolu
      Community Support

      Hi DavideBono97 ,

      This error typically occurs when the filter is correctly set up, but Power BI cannot locate a corresponding field in the dataset, resulting in it being treated as an empty string. Please consider the following checks:

      Table and column names: Ensure they match exactly with your dataset, including spaces, spelling, and special characters. For instance, verify that your table is named Calendar document and the column is Document - Anni trascorsi da ultimo reload.

      Remove aliases: If fields have been renamed in your report, use the original dataset field names.

      Value type: For numeric columns, input numbers without quotes (e.g., "values": [5]). For text columns, enclose values in quotes (e.g., "values": ["5"]).

      Test with Equals first: Begin by using "operator": "Equals" with a simple value to confirm the filter binds correctly. Once successful, you can switch to LessThan.

      For reference, here is a sample test filter:

      "reportLevelFilters": [
        {
          "$schema": "http://powerbi.com/product/schema#basic",
          "target": {
            "table": "Calendario documento",
            "column": "Documento - Anni trascorsi da ultimo reload"
          },
          "operator": "Equals",
          "values": [5]
        }
      ]

      If this test is successful, you can then update the operator to LessThan as needed.

      • DavideBono97's avatar
        DavideBono97
        Helper I

        Hi

        I try this solution but not works

        This is true name of column and table

        The value is numeric

        I try with Equal operator but not works

        It is possible the error is for the space on the column and table ?

        Thanks and sorry

    • DavideBono97's avatar
      DavideBono97
      Helper I

      Hi
      Thanks for the update

      With url filter it works

      With this string with special characters because my table and columns have the space

       

      &filter=Calendario_x0020_documento/Documento_x0020__x002D__x0020_Anni_x0020_trascorsi_x0020_da_x0020_ultimo_x0020_reload eq 1

       

      But in Api I don't expect to write it this way

      Could it be the fault of the spaces on the API too?

      Thanks to both of you AmosHersch  v-sshirivolu 

       

      • AmosHersch's avatar
        AmosHersch
        Microsoft Employee

        DavideBono97 did you try the same string with special characters in the API? It might be an issue with the spaces.