Monday
I wish to extract from PowerBI Datasets the metadata of all Measures, Relationships and Entities.
In VSCode I have a python script that connects to the PowerBI API using the Pyadomd module connecting via the XMLA endpoint. After much trial and error I've settled on this ADOMD approach as I've come to understand that Power BI's REST API for datasets doesn't directly provide an endpoint to list tables within a dataset, especially for Import datasets connected to an external source.
Below an example of my code which then works in VScode - essentially I can execute any DAX query I need.
import pandas as pd
# Include ADOMDClient in path before importing Pyadomd
import clr
dll_path = r"C:\Program Files\Microsoft.NET\ADOMD.NET\150\Microsoft.AnalysisServices.AdomdClient.dll"
clr.AddReference(dll_path)
from pyadomd import Pyadomd
DAX_query = """evaluate INFO.RELATIONSHIPS()"""
client_id = "<client_id>"
tenant_id = "<tenant_id>
client_secret = "<client_secret>"
workspace = "<workspace_name>"
catalog = "<catalog_name>"
connection_string = f"Data Source=powerbi://api.powerbi.com/v1.0/myorg/{workspace}; " \
f"Initial Catalog={catalog}; " \
f"User ID=app:{client_id}@{tenant_id}; " \
f"Password={client_secret}"
# Execute the query
with Pyadomd(connection_string) as conn:
with conn.cursor().execute(DAX_query) as result:
df_daxresult = pd.DataFrame(result.fetchall(), columns=[i[0] for i in result.description])
# Print Result
print(df_daxresult)
The issue now is getting this to work from within Databricks - which appears to be counter-intuitive given my use of the .Net runtime however there are online references to including ADOMD.dll in my DBFS FileStore and then Adding Reference to the path so that I can successfully "import Pyadomd".
I have however not managed to locate the ADOMD library for download and am wary if this is even the correct/best approach.
yesterday
Hello, many thanks for your question, so just to confirm, does the Power BI connector with Databricks is not a viable solution for you? https://learn.microsoft.com/en-us/azure/databricks/partners/bi/power-bi
yesterday
Hi Walter, thanks for this, I wasn't aware of the PowerBI Connector so this was good to read up on.
Unfortunately we do not yet have Unity Catalog set up so I understand the PowerBI Connector option is not valid for me just yet. Out of interest though, if I did have Unity Catalog configured, how would one interact/read from the PowerBI dataset?
yesterday
Publish Databricks Tables to a Power BI Dataset:
Catalog
in the sidebar to open Catalog Explorer.Use with BI tools
for a schema or Open in a dashboard
for a table.Publish to Power BI workspace
.Connect to Microsoft Entra ID
to authenticate.DirectQuery
or Import
.OAuth
or PAT (Personal Access Token)
. Databricks recommends using OAuth for fine-grained access control and user-level auditing.Publish as a new data set
or Use an existing data set
.Post-Publishing:
yesterday
Thanks Walter, but my focus is more about reading from PowerBI datasets and not publishing to them. I want to extract from a PowerBI semantic model the metadata of each entity, relationship and measure. PowerBI does have the REST API exposed but I'm unable to connect to the "tables" endpoint, for example, given my Import dataset connected to an external source.
Thanks for this detail though, it does help me broaden my context of Databricks.
2 hours ago
I understand, yes it seems that this is currently not possible, only option will be to export your dataset as a csv file and import it in Databricks.
Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.
If there isn’t a group near you, start one and help create a community that brings people together.
Request a New Group