Last active
April 16, 2025 01:47
-
-
Save bjulius/bbe97b5a954fc15fd58dea76e066e5b4 to your computer and use it in GitHub Desktop.
DAX Measure to Extract Data Model Info for Prompting AI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BIM Info = | |
VAR TableInfo = | |
ADDCOLUMNS ( | |
INFO.VIEW.TABLES (), | |
"Component", "Tables" | |
) | |
VAR ColumnInfo = | |
ADDCOLUMNS ( | |
INFO.VIEW.COLUMNS (), | |
"Component", "Columns" | |
) | |
VAR RelationshipInfo = | |
ADDCOLUMNS ( | |
INFO.VIEW.RELATIONSHIPS (), | |
"Component", "Relationships" | |
) | |
VAR MeasureInfo = | |
ADDCOLUMNS ( | |
INFO.VIEW.MEASURES (), | |
"Component", "Measures" | |
) | |
VAR Result = | |
TOCSV ( TableInfo ) | |
& TOCSV ( ColumnInfo ) | |
& TOCSV ( RelationshipInfo ) | |
& TOCSV ( MeasureInfo ) | |
RETURN | |
Result | |
// Authored by Brian Julius, Feb 2025 |
For more info about this technique, here's the link to my original LinkedIn post about it:
Love this!
There seems to be either limit to output size, or TOCSV (tried TOJSON as well) trips over some special characters - in large model I'm getting just few percent of Measures data, it is severely truncated.
Doesn't happen when I run INFO.VIEW.MEASURES directly.
@bjulius have you encountered this issue?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nalaka Wanniarachchi just came up with a really nice optimization of my DAX measure.
If instead of implementing this through a DAX measure, if you do it via a DAX query, it saves you the step of dragging the measure into the empty table visual.
Here's the DAX Query code:
EVALUATE
VAR TableInfo =
ADDCOLUMNS (
INFO.VIEW.TABLES (),
"Component", "Tables"
)
VAR ColumnInfo =
ADDCOLUMNS (
INFO.VIEW.COLUMNS (),
"Component", "Columns"
)
VAR RelationshipInfo =
ADDCOLUMNS (
INFO.VIEW.RELATIONSHIPS (),
"Component", "Relationships"
)
VAR MeasureInfo =
ADDCOLUMNS (
INFO.VIEW.MEASURES (),
"Component", "Measures"
)
VAR Result =
TOCSV ( TableInfo )
& TOCSV ( ColumnInfo )
& TOCSV ( RelationshipInfo )
& TOCSV ( MeasureInfo )
RETURN
{
Result
}
Now just hit F5 to run the query, click on the output cell and then select
Because the query requires no modification across reports, you can just include this in your startup template so you'll automatically have it available in every report you create.
Nice work, Nalaka!
