Forum Discussion
Looking for the Power BI API for MQuery
- 2 years ago
How do you plan to authenticate? Did you register an app in AD with the required scope?
$requestBody = @" { "queries": [{ "query": "EVALUATE TOPN(10,Dates,[Date])"}] ,"serializerSettings":{"includeNulls":true} } "@ Login-PowerBI $requestUrl = "datasets/xxx/executeQueries" $result = Invoke-PowerBIRestMethod -Method Post -Url $requestUrl -Body $requestBody $parsed = $result | ConvertFrom-JsonHere is a script with manual authentication.
How do you plan to authenticate? Did you register an app in AD with the required scope?
$requestBody = @"
{ "queries": [{ "query": "EVALUATE TOPN(10,Dates,[Date])"}]
,"serializerSettings":{"includeNulls":true}
}
"@
Login-PowerBI
$requestUrl = "datasets/xxx/executeQueries"
$result = Invoke-PowerBIRestMethod -Method Post -Url $requestUrl -Body $requestBody
$parsed = $result | ConvertFrom-Json
Here is a script with manual authentication.
"queries": [{ "query": "EVALUATE TOPN(10,Dates,[Date])"}]What is this sction of the script for?
- lbendlin2 years agoSuper User
That's an example of a DAX query. In your case you could use
EVALUATE INFO.PARTITIONS()
If you want all M Queries you would have to repeat the process with INFO.EXPRESSIONS()
Alternatively you could treat your semantic model as a SSAS endpoint and run the DMV queries directly.
Invoke-ASCmd -Server "powerbi://api.powerbi.com/v1.0/myorg/<workspace>" -Database "<semantic model>" -Query "select * from `$SYSTEM.TMSCHEMA_PARTITIONS" | Out-File -FilePath c:\users\xxx\Downloads\dmv.xml