PowerBI Connection: Possible to use ADOMDClient (or alternative)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 11:19 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 04:07 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 01:29 PM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 02:10 PM
-
Publish Databricks Tables to a Power BI Dataset:
- Sign in to your Databricks workspace and click on
Catalog
in the sidebar to open Catalog Explorer. - Select a compute resource from the drop-down list at the top right.
- Open a catalog and select the schema or tables to be published. Avoid selecting from a hive metastore or the samples catalog.
- On the upper right, click
Use with BI tools
for a schema orOpen in a dashboard
for a table. - Select
Publish to Power BI workspace
. - In the Connect to partner dialog, click
Connect to Microsoft Entra ID
to authenticate. - In the Power BI workspaces, select the Power BI workspace.
- In Dataset Mode, select either
DirectQuery
orImport
. - In Authentication Method in Power BI, select
OAuth
orPAT (Personal Access Token)
. Databricks recommends using OAuth for fine-grained access control and user-level auditing. - In Dataset Name, select
Publish as a new data set
orUse an existing data set
.
- Sign in to your Databricks workspace and click on
-
Post-Publishing:
- Once the dataset is published, it will be available in Power BI Online within 10 to 20 seconds, ready for report creation and analysis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-17-2024 05:50 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2024 06:07 AM
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.

