Trying to extract information about your tabular model? Here is a way to quickly extract relevant metadata for all common model elements (listed below).
Tables
Columns
Measures
Hierarchies
Data Sources
Relationships
Roles*
Row Level Security
Perspectives
Translations
Calculation Groups
KPIs
Object Level Security
Model
This can be done for any form of tabular model - a .bim file, database.json file, SSAS Server, Azure Analysis Services Server, or a Power BI Premium dataset. Power BI Premium datasets are able to do this via the XMLA endpoints as well as the support for Service Principals using the XMLA endpoints.
*Note that the Role metadata cannot yet be extracted for Power BI Premium datasets. This is expected to be possible once the XMLA endpoints feature becomes generally available later this month.
How to do it
1.) Download and install Tabular Editor.
2.) Download the C# script available here on GitHub.
3.) Open the script in a text editor and update the folderName parameter to a folder on your computer (this is where the metadata will go).
4.) Identify where you want to extract metadata from based on the options below.
.bim file
database.json file
SQL Server Analysis Services Server
Azure Analysis Services Server
Power BI Premium dataset
5.) Run the relevant script below accordingly from the command prompt. Make sure to update the items in orange, using the details below for assistance. All of the < and > signs are to be omitted and are simply placeholders.
.bim File
start /wait /d "C:\Program Files (x86)\Tabular Editor" TabularEditor.exe "<.bim file location>" -S "<C# script file location>"
database.json File (based on the Save-to-Folder technique)
start /wait /d "C:\Program Files (x86)\Tabular Editor" TabularEditor.exe "<database.json file location>" -S "<C# script file location>"
SSAS Server
start /wait /d "C:\Program Files (x86)\Tabular Editor" TabularEditor.exe "<Server Name>" "<Database Name>" -S "<C# script file location>"
Azure Analysis Services
start /wait /d "C:\Program Files (x86)\Tabular Editor" TabularEditor.exe "Provider=MSOLAP;Data Source=asazure://<westeurope>.asazure.windows.net/<AASServerName>;User ID=<xxxxx>;Password=<xxxxx>;Persist Security Info=True;Impersonation Level=Impersonate" "<Database Name>" -S "<C# script file location>"
Power BI Premium Dataset
start /wait /d "C:\Program Files (x86)\Tabular Editor" TabularEditor.exe "Provider=MSOLAP;Data Source=powerbi://api.powerbi.com/v1.0/myorg/<Premium Workspace>;User ID=app:<Application ID>@<Tenant ID>;Password=<Application Secret>" "<Dataset Name>" -S "<C# script file location>"
Note: If using Power BI Premium, make sure to enable XMLA Read/Write Endpoints by following the instructions here (note the minimum SKU to enable XMLA Read/Write is an A3).
Where to get the Azure Analysis Services Info
1.) Go to to the Azure Portal: portal.azure.com.
2.) In the search bar, search for 'Analysis Services'.
3.) Select your Azure AS instance.
4.) On the Overview tab, copy the Server Name (as highlighted below).
Where to get the app info
1.) Go to the Azure Portal: portal.azure.com.
2.) In the search bar, search for 'Azure Active Directory'.
3.) Copy the Tenant ID from the Overview page (as shown below).
4.) Go to the 'App Registrations' page (there is a link on the left navigation bar).
5.) Copy the Application ID (as shown below).
6.) Click on the 'Display Name' (here you will again see the App ID & Tenant ID).
7.) Click on 'Certificates & Secrets' (there is a link on the left navigation bar).
8.) Click 'New Client Secret', give it a name, and click 'Add'.
9.) Copy the client secret (make sure to write this down somewhere as you won't be able to go back and retrieve it from the portal).
Result
The resulting output of running these scripts is a set of text files with the extracted metadata - one text file for each of the model elements. The text files will appear in the folder specified in the folderName parameter within the C# script.
Simply copy these results into Excel for easy viewing and filtering.
Conclusion
Thanks to the TOM API and Tabular Editor, model metadata can easily be extracted programmatically. Additionally, this capability and much more is now available to folks using Power BI Premium thanks to the enabling XMLA Endpoints and Service Principals. Lastly, this gives a taste of the automation capabilities at your fingertips when using Tabular Editor for any tabular modeling scenario.
I would like to export the data model properties from multiple .bim files located in a folder (or in Azure that could be even better) , could that be possible? do it in one script, like the script you created for reports stored in a folder.
great post, pity i can't get it to work, have done everything as stated but get the error object reference not set to an instance of an objects, using the .bim method
I'm get a token recognition error? any thoughts on what's wrong? C:\Program Files (x86)\Tabular Editor>start /wait /d "C:\Program Files (x86)\Tabular Editor" TabularEditor.exe "C:\TabEdit\AcademicAlliance\Model.bim" -S "C:\TabEdit\Tabular-1.3.1\"
Tabular Editor 2.16.0 (build 2.16.7781.40242)
--------------------------------
Loading model...
Executing script 0...
line 1:2 token recognition error at: '\T'
line 1:10 token recognition error at: '\T'
line 1:24 token recognition error at: '"'
line 1:2 token recognition error at: '\T'
line 1:10 token recognition error at: '\T'
line 1:24 token recognition error at: '"'
Script compilation errors:
Error CS1056 on line 1, col 3: Unexpected character '\'
Error CS1056 on line 1, col 11: Unexpected character '\'
Error CS1010 on line 1, col 25: Newline in constant
Oh my word you are a life saver. I'm actually trying to write that script as we speak. Job done, you are a star!!!
Good post Michael! Comes very handy in day to day life. Thanks!