Forum Discussion
How to access M queries when Power BI Admin API returns empty tables array for PbixInImportMode data
- 1 year ago
Hi S_Kostiantyn ,
You cannot reliably retrieve M queries from “PbixInImportMode” datasets using the Admin getInfo endpoint because it often returns empty tables arrays for import‐mode PBIX files. Instead, you can use the Metadata Scanning (Lineage) APIs that allow you to initiate and retrieve a tenant‐wide scan, returning dataset schema and M expressions for each dataset. Alternatively, if the dataset is in Premium or Premium Per User capacity, you can connect via the XMLA endpoint using a tool such as SQL Server Management Studio or Tabular Editor to inspect the Tabular Object Model and locate the M queries under each table’s partition. For example, in SSMS you can run the following query to retrieve the M expressions:
SELECT * FROM $SYSTEM.TMSCHEMA_PARTITIONSThe export to PBIX option is another possibility, though less ideal for automation or large‐scale governance.
Best regards,
Hello!
Thank you very much for your detailed explanation and assistance!
I'd like to clarify regarding Microsoft Graph API: is it possible to use it to access data sources and M queries in Power BI reports?
In my current situation, using XMLA endpoints isn't optimal because I'm planning to integrate Power BI with Apache Airflow DAGs running on Linux. My Airflow environment is already running in Docker containers, which makes working with Windows-specific MSOLAP drivers particularly challenging.
I need a solution that works directly through API calls that can be installed via packages rather than requiring full software installations. Since I plan to integrate Power BI with Apache Airflow DAGs, I want to extract data sources from Power BI to create relationships within my data pipelines.
I'm looking for a way to programmatically access M queries from Power BI datasets through my Airflow pipelines. If Microsoft Graph API can provide this capability, or if there are other API-based approaches that can be implemented with standard Python packages in a Linux environment, that would be tremendously helpful.
Thank you again for your assistance!
Hi S_Kostiantyn
Currently, there is no direct API-based method for programmatically extracting M queries through standard Python packages.I recommend submitting the detailed feedback and ideas through Microsoft's official feedback channels, such as the Microsoft Fabric Ideas. . Feedback submitted through these channels is frequently reviewed by the product teams and can contribute to meaningful improvements.
If this post was helpful, please consider marking Accept as solution to assist other members in finding it more easily.