cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

PowerBI Connection: Possible to use ADOMDClient (or alternative)?

wi11iamr
New Contributor

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.

4 REPLIES 4

Walter_C
Databricks Employee
Databricks Employee

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 

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?

Walter_C
Databricks Employee
Databricks Employee

 

  • 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 or Open 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 or Import.
    • In Authentication Method in Power BI, select OAuth or PAT (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 or Use an existing data set.
  • 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.

 

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.

Connect with Databricks Users in Your Area

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