March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello
Is there a way to retrieve all measures from one pbix file and export or copy them to a txt file?
That would help for further documentation and as well mass changes if needed.
Cheers.
Solved! Go to Solution.
Hi @Ghuiles,
Yes there is. You can run a DMV query against the Tabular cube.
Essentially you need to connect to your Power BI Desktop instance from a tool such AS Sql Server Management Studio (or MDX Studio) and issue the following Query
Hello
I found a better solution, following that video: https://www.youtube.com/watch?v=rYlIp1PrBcA
Basically, in the DAX Studio, you click on MDSCHEMA_MEASURES.
You get an SQL, execute it and you got a lot of details on your measures.
That you can of course export directly to Excel.
Cheers
With May 2021 Power BI Desktop,
try this
https://github.com/JasonPad19/PowerBIScanner/blob/main/README.md
Is there any way I can retrieve the measures and dimensions of a particular chart?
This is the first result in google, so I'm posting here.
Today I discovered that the old method of unzipping a pbix file and exploring DataModelSchema works on PowerBI Template .pbit files.
Measures can be found in: model.tables.measures
Columns can be found in: model.tables.columns
Calculated Columns can be found in: model.tables.columns by filtering calculated = true
To streamline this, I've written a program in C#, but any language that parses JSON will work. Here is the basic C# source code. I just used linqpad to run it.
// using System; // using System.Linq; // using System.IO; // using System.Collections.Generic; // using Newtonsoft.Json void Main() { // get the JSON from pbit DataModelSchema string strFolderName = @"c:\path\to\file\"; string strFileName = @"DataModelSchema"; string strJson = File.ReadAllText(strFolderName + strFileName); // Convert the Json to a dynamic object dynamic oJson = JsonConvert.DeserializeObject<dynamic>(strJson); // Extract the tables to a list<dynamic> List<dynamic> oTables = new List<dynamic>(oJson.model.tables); // Remove hidden tables from the pull. These are only sysetm generated date tables. oTables = oTables.Where(t => t.isHidden != true).ToList(); foreach (var oTable in oTables) // Foreach Table, do something { Console.Write((string)oTable.name); // Output the table name if (oTable.measures != null) // If the table has measures { List<dynamic> oMeasures = new List<dynamic>(oTable.measures); foreach (var oMeasure in oMeasures) // Foreach measure { Console.Write(string.Format("\n\n\t\t{0} = {1}", (string)oMeasure.name, (string)oMeasure.expression)); // Write the measure and expression } } if (oTable.columns != null) // If the table has columns { Console.WriteLine(); // Insert a new line List<dynamic> oColumns = new List<dynamic>(oTable.columns); oColumns = oColumns.Where(c => c.type == "calculated").ToList(); // Filter on calculated columns only, but this could be removed for all foreach (var oColumn in oColumns) { Console.Write(string.Format("\n\n\t\t{0} = {1}", (string)oColumn.name, (string)oColumn.expression)); // Write the column and expression } } Console.WriteLine(); } }
Is there a way to do the reverse of this? I want to load the measures into the PBIX file from SQL.
I'm thinking of creating a measure library in SQL that would give all the different developers access to the list of measures. It also means measures can be edited and updated across multiple PBIX files.
You'll have to use DAX Studio http://daxstudio.codeplex.com/
How to do it is described here http://exceleratorbi.com.au/getting-started-dax-studio/
Hi @Sean.
I didn't realise you could use DAX Studio for DMV's but I guess that makes sence. I normally do my DMV work in SSMS, (or in Power BI Desktop itself) and that is a great article by @MattAllington
@Phil_Seamark wrote:
Hi @Sean.
I didn't realise you could use DAX Studio for DMV's but I guess that makes sence. I normally do my DMV work in SSMS, (or in Power BI Desktop itself@) and that is a great article by @MattAllington
Could you have a further explanation on how to do that in Power BI Desktop. I know the DMVs in SQL Server, Just wondering how to do that in Power BI Desktop. Thanks in advance.
Hmmm, maybe not.
You used to be able to unzip Power Pivot models and suck the formulas out of the xml files, but they have compressed/encrypted the data so not so straight forward.
Hello
I found a better solution, following that video: https://www.youtube.com/watch?v=rYlIp1PrBcA
Basically, in the DAX Studio, you click on MDSCHEMA_MEASURES.
You get an SQL, execute it and you got a lot of details on your measures.
That you can of course export directly to Excel.
Cheers
Hi!
Is there any way to do this for measures saved in a report on power bi services? Essentially, we have some measures in the data model, which can easily be retrieved by quering DMV, but how can I do this for the measures that are saved locally in a report?
I would like to do this without downloading the pbix-file so that we can have an automated solution for our reports on PowerBI Services.
🙂
I believe you'd have to have some form of premium SKU, and then you can connect to the analysis service endpoint for your workspace and dataset.
I'm not on the PowerBI team, but I have used PowerBI for 7 years.
Any idea how to obtain the measures that were created in a Power BI report and the Power BI report connects to an Analysis Services database in Direct Query mode?
That's great! Thanks for sharing
Yes the other thing I recommend is the Power Pivot Utilities Tool https://www.sqlbi.com/tools/power-pivot-utilities/
However whether you install the PP Util or not => start DAX Studio from EXCEL even if you just install the DAX Studio Add-In
This way when you are getting the List of ALL Measures in your Model you'll get the option to Output in Excel
If you don't start from within Excel you won't get that Option!
Hi guys!
Many Thanks @Sean and @Phil_Seamark! I learned a lot!
I used the SQL from Phil with the DAX studio.
Currently we are not using an SQL server. The data for PBI comes from Excel (Essbase).
Now i have the list of the measures, yes, but not their respective calculation. Is there a way to get them?
This would really help me to make mass changes.
Cheers
I haven't seen a DMV for this, but the PBIX file is just a .zip file so you could possibly parse the raw text (would be pretty ugly but you could do it in Power BI 🙂
Thanks again Phil!
I did the work manually.
Cheers
I think I'll have to find a better DMV for you too.
The one provided only returns 1 row against a PBI Desktop model. However it works beautifully against Tabular cubes.
If you run the following DMV query, it shows a list of the various meta data tables you can query.
SELECT * FROM $System.DBSchema_Tables
So for a list of Columns
SELECT * FROM $SYSTEM.DBSCHEMA_COLUMNS where Table_Schema = 'Model'
Beautiful 🙂
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
User | Count |
---|---|
93 | |
87 | |
84 | |
77 | |
49 |
User | Count |
---|---|
163 | |
148 | |
103 | |
74 | |
55 |