AI is meant to help us automate boring tasks, and what could be more boring than creating documentation for your Power BI semantic models? It’s such a tedious task that most people don’t bother; there’s also an ecosystem of third party tools that do this job for you, and you can also build your own solution for this using DAX DMVs or the new-ish INFO functions (see here for a good example). That got me wondering: can you use Fabric Data Agents to generate documentation for you? And what’s more, why even generate documentation when you can just ask a Data Agent the questions that you’d need to generate documentation to answer?
To test this idea out, I dug up a semantic model I’ve used for blog posts in the past with a simple star schema and a few measures:

Here are the definitions of the measures:
Units = SUM(Sales[SalesUnits])
Value = SUM(Sales[SalesValue])
Apples Value =
CALCULATE([Value], KEEPFILTERS('Product'[ProductName]="Apples"), USERELATIONSHIP('Product'[ProductID], 'Sales'[ProductID]))
Apples Value Forecast = [Apples Value] * 1.1
After publishing this model I created a Data Agent directly connected to it and found I couldn’t access the metadata I needed from it (I didn’t try too hard, but I don’t think it was possible) so I then created a second Import-mode semantic model, used the first as a data source and created a single table bound to the following DAX query using the INFO.CALCDEPENDENCY function:
EVALUATE INFO.CALCDEPENDENCY()
This second semantic model therefore contained a list of all the DAX calculations, their definitions and the dependencies between them, from the first semantic model. Here’s that table:

I then published this second semantic model, built a Data Agent on it, and used it for all my tests. I also added some instructions to the Data Agent – I freely admit I have no idea whatsoever about prompt engineering but after a bit of trial and error the following instructions did the trick:
You are a Power BI semantic model developer.
The CalcDependencies table contains the output of the DAX INFO.CALCDEPENDENCY() function for another Power BI semantic model. It contains information about the dependencies between the columns, tables, measures, calculated columns, calculated tables and relationships in that model.
Each row in the CalcDependencies table represents a dependency between two objects.
The combination of values in the OBJECT_TYPE, TABLE and OBJECT column uniquely identifies the object which is the source of the dependency.
The combination of values in the REFERENCED_OBJECT_TYPE, REFERENCED_TABLE and _REFERENCED_OBJECT columns uniquely identifies the object which is the target of the identity.
You can join the table to itself multiple times to find chains of dependencies between objects.
When I ask about dependencies, please include direct dependencies and also indirect dependencies, for example where one object has a dependency on another object which in turn has a dependency on the object I am asking about.
The EXPRESSION column contains the DAX definition of an object.
A value of CALC_COLUMN in the OBJECT_TYPE table indicates that the object is a calculated column.
First test: create some documentation. The following prompt:
Generate some documentation for the measures listed in the CalcDependencies table. Describe what each calculation does and how it works.
…generated the following output:
Here is the documentation for the measures listed in the CalcDependencies table, describing what each calculation does and how it works:
Measures
1. Units
- Definition:
SUM(Sales[SalesUnits]) - Description: The
Unitsmeasure calculates the total number of sales units. It does this by summing the values in theSalesUnitscolumn in theSalestable. This measure is useful for tracking the total quantity of items sold.
2. Value
- Definition:
SUM(Sales[SalesValue]) - Description: The
Valuemeasure calculates the total sales value. It achieves this by summing up the values in theSalesValuecolumn in theSalestable. This measure is essential for understanding the total revenue generated from sales.
3. Apples Value
- Definition:
CALCULATE([Value], KEEPFILTERS('Product'[ProductName]="Apples"), USERELATIONSHIP('Product'[ProductID], 'Sales'[ProductID])) - Description: The
Apples Valuemeasure calculates the total sales value specifically for the product “Apples.” It works by applying a filter to include only rows where theProductNamein theProducttable is “Apples.” Additionally, it uses a specific relationship between theProductandSalestables defined by theProductIDcolumns. This measure helps in analyzing the revenue generated from the sale of apples.
4. Apples Value Forecast
- Definition:
[Apples Value] * 1.1 - Description: The
Apples Value Forecastmeasure estimates the future sales value for the product “Apples” based on a forecasted increase. It multiplies the currentApples Valueby 1.1 (indicating a 10% increase). This measure is useful for predicting future revenue from apple sales.
These descriptions provide a clear understanding of what each measure does and how it works, helping anyone who looks at the documentation to comprehend the purpose and functionality of each calculation.
The verdict? More than good enough. To be honest, I was expecting the Data Agent to do a good job here though.
Second test: understand the dependencies between calculations. This is an interesting challenge because you can have chained relationships (ie measures that depend on other measures that depend on other measures etc) which makes the DAX harder to write. Also, you can’t easily understand dependencies by just looking at the output of INFO.CALCDEPENDENCIES – most of the third party tools mentioned above solve this by visualising the data with some kind of network diagram.
The following prompt:
Which measures would be affected if I deleted the SalesValue column on the Sales table?
…generated the following output:
If you delete the SalesValue column from the Sales table, the following measures will be affected:
- Measure Name: Value
- Definition:
SUM(Sales[SalesValue])
- Definition:
Since the Value measure directly depends on the SalesValue column, deleting the SalesValue column will cause the Value measure to break. Additionally, any measures that depend on the Value measure, such as Apples Value and Apples Value Forecast, will also be affected indirectly:
- Measure Name: Apples Value
- Definition:
CALCULATE([Value], KEEPFILTERS('Product'[ProductName]="Apples"), USERELATIONSHIP('Product'[ProductID], 'Sales'[ProductID]))
- Definition:
- Measure Name: Apples Value Forecast
- Definition:
[Apples Value] * 1.1
- Definition:
Therefore, deleting the SalesValue column will break the Value, Apples Value, and Apples Value Forecast measures.
The verdict? I’m impressed, this is useful.
Final test: can we generate a visualisation of the dependencies? A few months ago one of my colleagues showed me the Mermaid language for defining diagrams like this and the rather cool Markdown & Mermaid custom visual that allows you to display Mermaid diagrams in Power BI. The following prompt:
Generate an expression in the Mermaid diagramming language that shows all the measures in the model and the dependencies between them
…generated the following response:
Here is an expression in the Mermaid diagramming language that shows all the measures in the model and the dependencies between them:
graph TD
Units --> Units
Value --> Value
Apples_Value --> Value
Apples_Value_Forecast --> Apples_Value
Units["Units"]
Value["Value"]
Apples_Value["Apples Value"]
Apples_Value_Forecast["Apples Value Forecast"]
Explanation:
Unitsis a measure with no dependencies on other measures.Valueis a base measure.Apples Valuedepends on theValuemeasure.Apples Value Forecastdepends on theApples Valuemeasure, which in turn depends on theValuemeasure.
This Mermaid diagram visually represents all the measures in the model and the dependencies between them using arrows.
Pasting the expression in the response into the Markdown & Mermaid custom visual gave me the following:

I wasn’t particularly happy with those messy lines linking the Value and Units measures to themselves, but overall it does the job pretty well.
This blog post is already long enough and while these are simple tests, I think I’ve proved my point that Fabric Data Agents can be very useful when it comes to understanding the structure of a semantic model and the calculations in it. Bringing in data from other DAX INFO functions and tuning the AI Instructions would allow you to answer even more complex questions. I can also imagine a solution using Semantic Link Labs that not only dumps the data from DAX INFO functions for all your semantic models into a table in OneLake for consumption by a Data Agent, but also then uses the Data Agent SDK to automatically generate markdown documentation for those models, complete with diagrams. The possibilities are endless!
I will be happy when Power BI can show your first picture in this article; the Data Model schema as a picture. I include a screen print of the ‘Data Model schema’ with every report, and not much more. The Power Query (lineage view) is usually impossible to rearrange to fit in a print screen.
So far (I know I could) but I have not seen a actual need to include all measures.
It would be neat to have a free custom viz from MS that comes with everything.
Hi, interesting finding. Though it is not clear to me, how you implemented the function INFO.CALCDEPENDENCY() into a regular semantic model table. When I tried I got an error: “The function ‘INFO.CALCDEPENDENCY’ cannot be used in the expression of a measure, calculated column, or calculated table defined in the model.”
Sorry, I should have been more clear. I did everything in Power BI Desktop: I had two instances and then connected the second to the local Analysis Services running inside the first one (there are a couple of ways to do this but DAX Studio makes it easy to see the port number, eg https://biinsight.com/quick-tips-find-power-bi-desktop-local-port-number-with-model-explorer/)
I’m guessing here, but I suspect what Chris is doing is using the Analysis Services connector to connect to the published semantic model and supplying the DAX query as the optional parameter. That was how I got it to work
I love this idea. I’m immediately running into issues when I try to implement it, though, some sort of problem with permissions on the original semantic model. When I open DAX Query in the second semantic model, connected to the one I want to evaluate, running EVALUATE INFO.CALCDEPENDENCY() immediately gets me a “500: [user] does not have Discover permissions” error. I can’t find any mention of something called Discover permissions in the documentation; we’re in a Premium capacity that I’m the admin of, and Read/Write is turned on for XMLA endpoints, so I dunno what I’m missing.
Remember that Semantic Models are like baby OLAP cubes. “Discover permission” is basically the same as “Cube Admin”. Make sure your login is recognized as a semantic model admin.
Thank you for the inspirational post !
## Install Fabric Sematic Link
%pip install semantic-link
%load_ext sempy
## Import Libraries
import pandas as pd
import numpy as np
## Fabric Imports
import sempy.fabric as fabric
import pyspark.sql.functions as F
## Get Reference to Power BI Data
df_datasets = fabric.list_datasets()
df_datasets
dataset = “MyDataset”
## Examine Power BI Data Model
from sempy.relationships import plot_relationship_metadata
relationships = fabric.list_relationships(dataset)
plot_relationship_metadata(relationships)
fabric.list_measures(dataset)
This is such a clever use of Fabric Data Agents! I hate writing documentation for my Power BI models, so the idea of automating it is fantastic. The step-by-step approach with the secondary model is really insightful. It makes me wonder if you could use a similar technique with a mermaid syntax guide to automatically generate data lineage diagrams from these dependencies. That would be the ultimate documentation combo!
This is such a cool use of Fabric Data Agents! Automating documentation for Power BI models is a game-changer; it saves so much time. I’ve been looking into different ways to visualize data processes, and I even found a great mermaid syntax guide recently for making diagrams. Combining that kind of visual documentation with an AI agent that can explain the logic behind measures would be the ultimate setup. Really impressive stuff!