Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
pgelli
Microsoft Employee
Microsoft Employee

Get Table information from dataset Programmatically

Hi All,

 

Is there a way to programatically get the information of datasource & tables used in a dataset (like some kind of metadata). 
I saw there is a GetDataSet API, but that works on the datasets that are published using REST API. It will be practically impossible for us to publish a report using REST API given the amount of data we have. 

Any suggestions please?  

14 REPLIES 14
lbendlin
Super User
Super User

You can use any XMLA client (like SSMS, DAX Studio, ALM Toolkit etc) to connect to the XMLA endpoint of the dataset (assuming, of course, that you have access to the dataset) and pull down all the meta data.

pgelli
Microsoft Employee
Microsoft Employee

That is good information. Thanks @lbendlin . I see that it is only supported for PowerBI premium subscriptions. 
Currently we don't have PowerBI premium. Do you know of a way which can work for us with Standard PowerBI subscription & workspace.

Apologies, i did not qualify that. I have no experience outside of Premium. Maybe you need to be made a workspace member?

pgelli
Microsoft Employee
Microsoft Employee

So I got hold of a premium workspace and am able to connect to the XMLA endpoint. 
So far, I could get information like tables and columns from dataset perspective.

We want to actually find the source table information, not the ones created in powerbi report/dataset. Sorry if that was not clear in my initial post.
@lbendlin is there a way to get the source table information and the actual queries which are used to create the dataset tables.

select * from $SYSTEM.TMSCHEMA_PARTITIONS

pgelli
Microsoft Employee
Microsoft Employee

Thanks @lbendlin. I tried that at I dont see information of actual source in response. 
I still see the information about dataset tables, not the actual source SQL tables.

Now you got me really confused.  Are you after the schema information?

 

See if this blog helps you.

 

https://blog.crossjoin.co.uk/2020/07/05/why-is-power-bi-running-my-sql-query-twice/

pgelli
Microsoft Employee
Microsoft Employee

Sorry for the confusion @lbendlin .
My need is to programatically find the list of source tables which are backing a given powerbi report.

That's what I gave you with the DMV query.  You need to take that M code and parse it. It contains the server, database and query.

 

Annotation 2020-07-17 170405.png

Anonymous
Not applicable

I had the same problem as @pgelli when using @lbendlin 's suggestion of SELECT * FROM $SYSTEM.TMSCHEMA_PARTITIONS; I was receiving the DAX QueryDefinitions and not the M Query defintions (super useful, just not what I needed).  What solved it for me was instead using  SELECT * FROM $System.DISCOVER_M_expressions.  Hopefully this saves someone else some time for this use case.

pgelli
Microsoft Employee
Microsoft Employee

@lbendlin , I am afraid I am getting different results for that query:

pgelli_1-1595344834851.png

 


These are not the tables present in our Source. Am I missing something? 

Most likely you connected to the wrong endpoint. Different dataset maybe?

pgelli
Microsoft Employee
Microsoft Employee

I verified that I am looking at right dataset. However, PowerBI report is built using "import" and not "direct query".
Does it make a difference @lbendlin ?

No, once you access the dataset it doesn't matter much if  the query connection type is import/ direct query or mixed.  

 

I just tried it with one of my direct query datasets and got the expected result. 

 

As expected it will not work at all with live connections.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors