March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi,
I'm connecting fine to the PowerBI API however I can't run DAX queries. My end game is to assit the process of ascertaining what datasources and tables are used by what PowerBI reports.
I'm using the following endpoint as shown from Datasets - Execute Queries - REST API (Power BI Power BI REST APIs) | Microsoft Learn:
I'm sending the following JSON to the API:
{
"queries": [
"select * from $SYSTEM.TMSCHEMA_PARTITIONS"
],
"serializerSettings": {
"includeNulls": false
},
"impersonatedUserName": null
}
I'm getting the following error...
"message":"Error converting value \"select * from $SYSTEM.TMSCHEMA_PARTITIONS\" to type 'Microsoft.InfoNav.Explore.ServiceContracts.Internal.ExecuteDatasetQuery
Solved! Go to Solution.
HI @tech49,
As the document mentions, current this API only support to send Dax query and T-SQL query should not be suitable for this API usages:
Executes Data Analysis Expressions (DAX) queries against the provided dataset. The dataset must reside in My workspace or another workspace.
Datasets - Execute Queries - REST API (Power BI Power BI REST APIs) | Microsoft Learn
Data Analysis Expressions (DAX) Reference - DAX | Microsoft Learn
Regards,
Xiaoxin Sheng
Given your end game is to ascertain datasource and tables per report, assuming you want something to run across the whole tenant. If this is the case, you would be better served using the Scanner APIs.
All of the following can be obtained from GetScanResult:
Datasets will give you Tables and Datasources (Tables is simply 'tables, Datasources, you will get from datasourceUsages[datasourceInstanceId].
There are many ways you can get to this data, depending on your preference. Personally, I've extended this solution Extracting Power BI metadata with Data Factory (part 1) – justB smart but if you don't need to store the data, the Power BI REST API Connector is much faster to get running Power BI REST API Connector — The Power User.
With your datasourceInstanceId you can related datasets to datasourceInstances (this will then give you more details about that particular datasource.
You can then use reports[datasetid] to link all the above back to your report.
Admin - WorkspaceInfo GetScanResult - REST API (Power BI Power BI REST APIs) | Microsoft Learn
Ok,
I found the first part of my problem, I serialised the JSON incorrectly.
I should have labelled the as a "query", as below
{
"queries": [
"query": "select * from $SYSTEM.TMSCHEMA_PARTITIONS"
],
"serializerSettings": {
"includeNulls": false
},
"impersonatedUserName": null
}
using that format, I can send a query, however I can't get a TMSCHEMA_PARTITIONS, Now I'm getting
HI @tech49,
As the document mentions, current this API only support to send Dax query and T-SQL query should not be suitable for this API usages:
Executes Data Analysis Expressions (DAX) queries against the provided dataset. The dataset must reside in My workspace or another workspace.
Datasets - Execute Queries - REST API (Power BI Power BI REST APIs) | Microsoft Learn
Data Analysis Expressions (DAX) Reference - DAX | Microsoft Learn
Regards,
Xiaoxin Sheng
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
8 | |
3 | |
2 | |
1 | |
1 |
User | Count |
---|---|
6 | |
3 | |
2 | |
2 | |
2 |