How did I keep my Power BI dataset measures documented and up to date?
One thing that often happens is when users are using a dataset, they want to know which measures are available. And not only that sometimes they want to know the measure definition.
This got me thinking and how best could I give this to the users in my organization to be able to find this information quickly and easily.
In the past this was a manual effort not only to export the measures, but also to maintain a document, so that as measures are added, updated, or deleted I would then need to manually update some document.
Yep, you guessed it I created a Power BI report which has got all the measures and their measure definitions, which will update with the dataset! And I show you how I did this below.
Connecting to my PPU/Premium Dataset
The first steps were for me to connect to the PPU/Premium dataset via the XMLA Endpoint.
This allowed me to be able to define the query I wanted to run.
- I clicked on Get Data and selected “SQL Server Analysis Services”
-
I then put in my PPU/Premium App Workspace URL
- EG: powerbi://api.powerbi.com/v1.0/myorg/PPU%20Space%20Tests
-
I then put in my dataset name
- EG: Exact Aggs – PPU
-
I then change the data source to be “Import”
- This allowed me to then specify an MDX or DAX query
-
In the MDX or DAX Query I think put in the following DMV
select * from $SYSTEM.MDSCHEMA_MEASURES
- This is what it looks like below (NOTE: I have changed my PBIX file to use parameters)
-
I then clicked Ok, the first time I connected I had to log in and I chose “Microsoft account”
- I then loaded the data into the Power Query Editor
- I then copied the above table but changed it to use another DMV, which had slightly different properties that I wanted to capture
- I then shaped the data and got it into the format that I required.
- Finally, I loaded it to my dataset.
Creating the Power BI Report
I then created the Power BI Report as shown below.
I created a slicer with the search functionality, so that users could search for the measure.
I also created the last time the dataset has been refreshed to know how up to date the measures are.
Finally, I also added in the Measure Modified date to know when last it was updated.
Summary
In summary I have shown you how I connected to my dataset and got all the measures and their definitions.
Here is the link to the PBIT file that I created: PPU – Measure Definitions.pbit
If there are any comments, please let me know.
Thanks for reading!
Do you know how to get the Source code? I tried both TMSCHEMA_EXPRESSIONS and DISCOVER_M_EXPRESSIONS but that seems to NOT bring Loaded tables. In fact the exact opposite, when I do SELECT * FROM DISCOVER_M_EXPRESSIONS, all the queries that are brought in are ones that are NOT loaded into my model. Do you have any insight into that? I would LOVE to be able to somehow parse out our Oracle SQL queries and have them all in one place. We do so many upgrades it is a nightmare trying to figure out what PBIX files have what SQL code. Any help would be appreciated!
Hi Nate,
I think you could actually do this via the Power BI REST APIs
https://docs.microsoft.com/en-us/rest/api/power-bi/admin/datasets-get-datasets-in-group-as-admin#asmashupexpression
Ok thanks. I’ve never used those before so I’m not really sure where to begin on that but I’ll take a look. Do you know or have any examples of anyone pulling out the source code into a PBI?
Hi Nathan,
There is a way to script it out using Tabular Editor, which you could then use to parse and get all the data. That is the only way I currently know.
This is great Gilbert! I did something similar and this helped the BI developers and biz users immensely. However, I was trying to parameterize so that it can point to different models (tabular) and different environments (dev, UAT, prod) for the selected model. I was able to do this successfully for picking a tabular model but wasn’t able to parameterize the database environment. Do you have any insights on this or could take your solution to do something like this?
Appreciate all your insights and knowledge sharing blogs.
Thanks,
Sree
Hi Srikanth,
You should be able to change the database with the dataset name in Power BI Desktop?
hi,
About the [DISCOVER_SESSIONS], how long does DMV keep user session record?
I really want to know that , thanks!
Hi Jason
I had a look and I am not entirely sure how long it persists that information for!