Forum Discussion

ManasRout's avatar
ManasRout
Resolver II
1 month ago
Solved

How to Know Which Report Storage Mode is Import or Direct Query In a Workspace

Hi Team, Is there any way I can check in a workspace which report is used by import mode and direct query mode in a workspace because I have 150 reports in this workspace which I don't want to check manually. Also is it possible to use Power bi rest Api and export to an excel file for this details if yes can you let me know the steps how to achieve it.

  • Hi ManasRout,

     

    As stated in previous thread, Storage Mode (DirectQuery, Import, Composite) is determined based on the Semantic Model and not the report.

     

    Using Get Datasets In Group – REST API, you can get all the datasets in a Workspace in a JSON format by adding the WORKSPACE_ID (groupId) in the API call.

    Use ContentProviderType property to identify whether a semantic model is Import, DirectQuery, or CompositetargetStorageMode should not be used for this purpose, as it doen'st reflect the semantic model's connectivity mode.

    Reference - Datasets - Get Datasets In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn

     

    NOTE - ContentProviderType may not always be returned, depending on the API called, caller permissions, and the availability of the data in the Power BI database as stated in the Microsoft reference. If the property is present in the JSON response, the following solution can be used.

     

    Using Power Query, you can call the Power BI REST APIs to retrieve the list of Reports and Datasets, merge them, and create a report that shows which reports are connected to Import, DirectQuery, or Composite semantic models.

     

    1. Retrieve Datasets - 

    In Power BI Desktop β†’ Get Data β†’ Blank Query, open Advanced Editor and paste the following code. Replace WORKSPACE_ID with your workspace ID and BEARER_TOKEN you can find in the API call page (highlighted in grey). When prompted for credentials, choose Anonymous.

    This query returns DatasetID, DatasetName, and StorageMode. The ContentProviderType property can be used to identify whether the semantic model is Import, DirectQuery, or Composite.

    let
        WorkspaceId = "WORKSPACE_ID",
        Token = "BEARER_TOKEN",
    
        Source =
            Json.Document(
                Web.Contents(
                    "https://api.powerbi.com",
                    [
                        RelativePath = "v1.0/myorg/groups/" & WorkspaceId & "/datasets",
                        Headers = [
                            Authorization = "Bearer " & Token,
                            Accept = "application/json"
                        ]
                    ]
                )
            ),
    
        Value = Source[value],
        ConvertToTable = Table.FromList(Value, Splitter.SplitByNothing()),
        ExpandData = Table.ExpandRecordColumn(
            ConvertToTable,
            "Column1",
            {"id","name","ContentProviderType"},
            {"DatasetID","DatasetName","StorageMode"}
        )
    in
        ExpandData

     

    2. Retrieve Reports - 

    Using Get Reports In Group – REST API, you can get all the reports in a Workspace in a JSON format by adding the WORKSPACE_ID (groupId) in the API call.

    Reference - Reports - Get Reports In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn

     

    Create another Blank Query and paste the following code to retrieve all reports from the same workspace.

    This query returns ReportID, ReportName, and DatasetID.

    let
        WorkspaceId = "WORKSPACE_ID",
        Token = "BEARER_TOKEN",
    
        Source =
            Json.Document(
                Web.Contents(
                    "https://api.powerbi.com",
                    [
                        RelativePath = "v1.0/myorg/groups/" & WorkspaceId & "/reports",
                        Headers = [
                            Authorization = "Bearer " & Token,
                            Accept = "application/json"
                        ]
                    ]
                )
            ),
    
        Value = Source[value],
        ConvertToTable = Table.FromList(Value, Splitter.SplitByNothing()),
        ExpandData = Table.ExpandRecordColumn(
            ConvertToTable,
            "Column1",
            {"id","name","datasetId"},
            {"ReportID","ReportName","DatasetID"}
        )
    in
        ExpandData

     

    3. Merge both the queries by Reports[DatasetID] = Datasets[DatasetID]

    4. Expand DatasetName & StorageMode

    5. Add Custom Column using below code. Have only required columns and rename accordingly in the table.

    if [StorageMode] = "PbixInImportMode" then "Import"
    else if [StorageMode] = "PbixInDirectQueryMode" then "DirectQuery"
    else if [StorageMode] = "PbixInCompositeMode" then "Composite"
    else [StorageMode]

     

    Sample Result - 

     

    This will provide a consolidated inventory of reports and their corresponding semantic model storage modes for the selected workspace.
     
    AI Disclosure - Microsoft Copilot was used to assist with wording refinement, grammar correction, and improving the clarity and readability of this response. The solution provided was manually tested, validated, and reviewed to the best of my knowledge.
     
    πŸ’‘ Helpful? Give a Kudos πŸ‘ β€” keep the community growing
    βœ… Solved your issue? Mark as Solution βœ”οΈ β€” help others find it faster

    Best regards,
    Rupasree Achari | BI & Fabric Analytics Engineer 

     

5 Replies

  • Rupa01's avatar
    Rupa01
    Solution Sage

    Hi ManasRout,

     

    As stated in previous thread, Storage Mode (DirectQuery, Import, Composite) is determined based on the Semantic Model and not the report.

     

    Using Get Datasets In Group – REST API, you can get all the datasets in a Workspace in a JSON format by adding the WORKSPACE_ID (groupId) in the API call.

    Use ContentProviderType property to identify whether a semantic model is Import, DirectQuery, or CompositetargetStorageMode should not be used for this purpose, as it doen'st reflect the semantic model's connectivity mode.

    Reference - Datasets - Get Datasets In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn

     

    NOTE - ContentProviderType may not always be returned, depending on the API called, caller permissions, and the availability of the data in the Power BI database as stated in the Microsoft reference. If the property is present in the JSON response, the following solution can be used.

     

    Using Power Query, you can call the Power BI REST APIs to retrieve the list of Reports and Datasets, merge them, and create a report that shows which reports are connected to Import, DirectQuery, or Composite semantic models.

     

    1. Retrieve Datasets - 

    In Power BI Desktop β†’ Get Data β†’ Blank Query, open Advanced Editor and paste the following code. Replace WORKSPACE_ID with your workspace ID and BEARER_TOKEN you can find in the API call page (highlighted in grey). When prompted for credentials, choose Anonymous.

    This query returns DatasetID, DatasetName, and StorageMode. The ContentProviderType property can be used to identify whether the semantic model is Import, DirectQuery, or Composite.

    let
        WorkspaceId = "WORKSPACE_ID",
        Token = "BEARER_TOKEN",
    
        Source =
            Json.Document(
                Web.Contents(
                    "https://api.powerbi.com",
                    [
                        RelativePath = "v1.0/myorg/groups/" & WorkspaceId & "/datasets",
                        Headers = [
                            Authorization = "Bearer " & Token,
                            Accept = "application/json"
                        ]
                    ]
                )
            ),
    
        Value = Source[value],
        ConvertToTable = Table.FromList(Value, Splitter.SplitByNothing()),
        ExpandData = Table.ExpandRecordColumn(
            ConvertToTable,
            "Column1",
            {"id","name","ContentProviderType"},
            {"DatasetID","DatasetName","StorageMode"}
        )
    in
        ExpandData

     

    2. Retrieve Reports - 

    Using Get Reports In Group – REST API, you can get all the reports in a Workspace in a JSON format by adding the WORKSPACE_ID (groupId) in the API call.

    Reference - Reports - Get Reports In Group - REST API (Power BI Power BI REST APIs) | Microsoft Learn

     

    Create another Blank Query and paste the following code to retrieve all reports from the same workspace.

    This query returns ReportID, ReportName, and DatasetID.

    let
        WorkspaceId = "WORKSPACE_ID",
        Token = "BEARER_TOKEN",
    
        Source =
            Json.Document(
                Web.Contents(
                    "https://api.powerbi.com",
                    [
                        RelativePath = "v1.0/myorg/groups/" & WorkspaceId & "/reports",
                        Headers = [
                            Authorization = "Bearer " & Token,
                            Accept = "application/json"
                        ]
                    ]
                )
            ),
    
        Value = Source[value],
        ConvertToTable = Table.FromList(Value, Splitter.SplitByNothing()),
        ExpandData = Table.ExpandRecordColumn(
            ConvertToTable,
            "Column1",
            {"id","name","datasetId"},
            {"ReportID","ReportName","DatasetID"}
        )
    in
        ExpandData

     

    3. Merge both the queries by Reports[DatasetID] = Datasets[DatasetID]

    4. Expand DatasetName & StorageMode

    5. Add Custom Column using below code. Have only required columns and rename accordingly in the table.

    if [StorageMode] = "PbixInImportMode" then "Import"
    else if [StorageMode] = "PbixInDirectQueryMode" then "DirectQuery"
    else if [StorageMode] = "PbixInCompositeMode" then "Composite"
    else [StorageMode]

     

    Sample Result - 

     

    This will provide a consolidated inventory of reports and their corresponding semantic model storage modes for the selected workspace.
     
    AI Disclosure - Microsoft Copilot was used to assist with wording refinement, grammar correction, and improving the clarity and readability of this response. The solution provided was manually tested, validated, and reviewed to the best of my knowledge.
     
    πŸ’‘ Helpful? Give a Kudos πŸ‘ β€” keep the community growing
    βœ… Solved your issue? Mark as Solution βœ”οΈ β€” help others find it faster

    Best regards,
    Rupasree Achari | BI & Fabric Analytics Engineer 

     

  • Hi ManasRout ,
    One clarification first that makes this easier: storage mode belongs to the semantic model, not the report. So the task is really "which mode does each model use, and which reports sit on top of it". 

    The field you need: contentProviderType
    The dataset object in the REST API includes a contentProviderType property with values like PbixInImportMode and PbixInDirectQueryMode. Don't confuse it with targetStorageMode β€” that one is about large-model storage format (Abf/PremiumFiles), not Import vs DirectQuery.
    https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/get-datasets-in-group


    My earlier answer was to use Powershell, but i see that other in the thread have posted a better answer through Power Query.

     

    Note;

    If contentProviderType comes back empty, it may depend on the API used, caller permissions, or metadata availability. If you have Fabric/Power BI admin rights, test the admin dataset API as a second check.

     

    AI disclosure: Microsoft Copilot was used to help with wording and structure. I manually reviewed the technical content before posting and validated it against the Microsoft Learn reference above.

  • Hi ManasRout

    There is a datasets API, however the targetStorageMode is a little misleading. This tells you the storage mode of the model as a whole, not of tables inside the model. Generally you will see either Abf or PremiumFiles indicating if the model is in large storage mode or not. 

    https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/get-datasets-in-group

     

    What I think you actually want is to scan the XMLA endpoint to get the storage mode for each table inside your models, as models can have a combination of DirectQuery, DirectLake, and Import mode tables all in the same model. 

     

    I don't think there is a way to do this for all models in the workspace at once, it needs to be done individually, however you should be able to use the datasets API above to get a list of all datasets, and then programatically  each one in a loop. 

  • v-saisrao-msft's avatar
    v-saisrao-msft
    Community Support

    Hi ManasRout,

    Checking in to see if your issue has been resolved. let us know if you still need any assistance.

     

    Thank you.