Documenting Power BI – Data Model

I wanted to find an easy-to-use documentation script for my data models. In Tabular Editor`s documentation there is a useful script for generating documentation.

I thought I will use what Daniel Otykier created as a starting point and try to create a solution that can give me all the information I would like to get.

After a few hours I managed to get to a stage where I was quite satisfied with the result and wanted to share it with you to help in your documentation needs.

What I have created is still not a perfect solution and has some manual steps, but at least you can create a documentation in less than 2 minutes.

At the end of this blog post you will find a downloadable template excel where all the transformations are setup you just need to paste in some data from Tabular Editor.


The easiest way to explain how the solution works is to show you so I created a short video about it.

Documenting a Power BI dataset

This is my first step into video blogging, so I hope you find the content useful.

Documentation Script:

Advanced scripting in Tabular Editor

This script will give you information about your:

  • Tables
  • Columns
  • Measures
  • Hierarchies
// Collect all measures, columns, hierarchies and tables (ignore automatically generated entities):
var objects = Model.AllMeasures.Cast<ITabularNamedObject>()
      .Concat(Model.AllColumns.Where(c => !c.Table.Name.Contains("Template") 
                                       && !c.Table.Name.Contains("LocalDate"))
      .Concat(Model.AllHierarchies.Where(h => !h.Table.Name.Contains("Template") 
                                       && !h.Table.Name.Contains("LocalDate"))
      .Concat(Model.AllLevels.Where(h => !h.Table.Name.Contains("Template") 
                                       && !h.Table.Name.Contains("LocalDate"))

// Get their properties:
var tsv = ExportProperties(objects,"Name,ObjectType,Parent,Description,FormatString,DataType,Expression,IsHidden,DisplayFolder,Synonyms,DataCategory");

// Output to screen (can then be copy-pasted into Excel):

Get Relationship info:

I have not spent enough time with the script to figure out how I can get the relationship information out but found an effortless way to do it.

As shown in the video, you can select all the relationships and copy them as json data into Excel is relatively easily.

Download the Excel file:

This will contain 2 grey sheets where you can insert the extracted information. One is for the script results the outer is for the relationship copy results.

There are 5 blue sheets that will populate with data once you refreshed the excel file (after inserting the extracts). There is a sheet for Tables, Columns, Measures, Hierarchies, Relationships.


Hope this little solution can help you with your documentation needs going forward.

If you would like to get notified about similar post, then please subscribe to the newsletter.

Please follow and like us:

About the author

Mihaly Kavasi

Data-driven Decision-Making Enthusiast.
Power BI Expert and Trainer. Helping organizations and communities to use data effectively.
Big fan of RE and Electric cars.
Working @ Avanade

View all posts