I was working with a client last week and the unthinkable happened. The client made a simple editing mistake inside the Measure editing dialogue box and it corrupted the Power Pivot workbook. We could still edit the corrupt workbook, but the Pivot Tables stopped working. Oh No!! Now what? He had written half a dozen new Measures and all that effort now seemed to be lost.
Luckily we had incremental backups of the workbook we were developing. Well actually it wasn’t luck – it was good forward planning. Even though Power Pivot is an excellent tool, anyone that uses it will know it is a bit flaky and it can cause problems when editing. As a precaution I always keep incremental backups of my workbooks when doing data modelling work. I have optimised this process using an incremental backup macro I created. You can read about that here and even download the VBA code to use yourself.
OK, but we still had a problem. We had a backed up copy of the workbook, but this backed up copy didn’t contain the last 30 mins work – about half a dozen DAX formulae. Power Pivot doesn’t allow you to export the Measures and then reuse them. But there is a solution using DAX Studio.
What is DAX Studio?
DAX Studio is a great tool that allows you to do many things with your Excel Power Pivot data models. It will allow you to use DAX as a query language to interrogate your data model and many other things. One of those “other things” it allows you to do is get a list of all of your DAX Measures in a new sheet in your workbook.
You can read more about DAX Studio and download it here. Note I installed version 2.2.1 today and it didn’t work for me. I am currently using version 2.1.1 and that works fine.
Step by Step Instructions on how to Extract Measures
This is how you go about extracting your Measures from an Excel Workbook.
First you need to install DAX Studio. Just download it from the link above. Don’t run DAX Studio when prompted to do so immediately after the install. Just exit after the install is finished. Make sure you have Excel closed when you run the install.
The next step is to open Excel, open your work book and then run DAX Studio. You will find DAX Studio on the Add-Ins tab on the Excel Ribbon.
When you launch, it will ask you which Data Source you want to connect to. In this demo I am connecting to a data model in an Excel workbook. This is what most Excel users will normally do. It will also work with a tabular instance of SSAS if you have these.
Once connected, you will see a list of tables in your Power Pivot Data model on the left. The next step is to switch to the DMV tab down the bottom of the screen.
When you have clicked on the DMV tab, you will see a list of objects in the left hand panel. Locate the one called MDSCHEMA_MEASURES and drag it into the editing pane on the right.
DAX Studio will then automatically write the query required to extract the Measures from the workbook.
Before executing the query you should change the output settings so it sends the results to a clean spreadsheet within your workbook. When done, click the Run button to execute the query.
After you have run the query, you will notice there is a new sheet in your workbook that contains all the detail of your measures.
But there is a lot of information here that you probably don’t care about. You can manually clean up the data by deleting what is not important. You really just need the name and the formula (columns D and N) and maybe a couple of others. I have written a small VBA macro to clean up the DAX Studio output for this exercise. Feel free to use this code if you like. If you don’t know how to use this VBA code ,you can read about how to do that here.
Sub CleanDAXStudioMeasures() Application.ScreenUpdating = False Columns("A:B").Delete Shift:=xlToLeft Columns("C:D").Delete Shift:=xlToLeft Columns("C:I").Delete Shift:=xlToLeft Columns("D:G").Delete Shift:=xlToLeft Columns("E:E").Delete Shift:=xlToLeft Columns("C:C").ColumnWidth = 50 Range("A1").Select While Selection.Value <> "" If Left(Selection.Value, 1) = "$" Then Selection.EntireRow.Delete Else If Left(Selection.Offset(0, 1).Value, 1) = "_" Then Selection.EntireRow.Delete Else Selection.Offset(1, 0).Select End If End If Wend Range("A1").Select Selection.EntireColumn.Delete Range("C1").Value = "Table" Range("E1").Value = "Full Formula" ActiveSheet.ListObjects.Add(xlSrcRange, Range("A1").CurrentRegion, xlYes).Name = "Table1" Range("E2").FormulaR1C1 = "=RC[-4]&"":=""&RC[-3]" Columns("A:E").EntireColumn.AutoFit Application.ScreenUpdating = True End Sub
After running the above Macro, you will end up with a table that contains the relevant information including the following full formulae in the last column.
You can simply cut and paste these formula one at a time into the calculation area at the bottom of each table inside the Power Pivot window of you last backed up copy of the workbook. Note you will then need to manually apply any data formatting you need.
Thanks for putting this up. It’s understandably done.
https://proisotrepl.com/product/baclofen/
I am in point of fact thrilled to glance at this blog posts which consists of tons of profitable facts, thanks towards providing such data. https://ondactone.com/simvastatin/
Hi there! This post couldn’t be written any better! Reading through this post reminds me of my previous room mate! He always kept talking about this. I will forward this article to him. Pretty sure he will have a good read. Thank you for sharing!
It is not possible to become uncircumcised, as circumcision is a surgical procedure that removes the
foreskin from the penis.
Magnificent beat ! I wish to apprentice while you amend your site, how could i subscribe for a blog web site? The account aided me a acceptable deal. I had been tiny bit acquainted of this your broadcast provided bright clear concept
This website really has all of the information and facts I needed adjacent to this participant and didn’t identify who to ask. cialis professional 20 mg prix
The thoroughness in this section is noteworthy. https://ursxdol.com/get-metformin-pills/
More text pieces like this would urge the web better. isotretinoin 40mg
Thanks recompense sharing. It’s outstrip quality. on this site
sildenafil 100 mg, – buy viagra qatar buy viagra vancouver
he blog was how do i say it… relevant, finally something that helped me. Thanks
ranitidine 300mg us – order zantac 300mg without prescription buy zantac 300mg without prescription
tadalafil oral jelly – https://ciltadgn.com/ how long does it take for cialis to take effect
cenforce online order – https://cenforcers.com/ cenforce online order
buy fluconazole 100mg without prescription – fluconazole tablet forcan cheap
buy generic amoxil over the counter – combamoxi.com buy generic amoxil for sale
Great post, I believe people should acquire a lot from this blog its very user friendly.
so much good info on here, : D.
MultiChain
Hello, i feel that i saw you visited my website so i got here to “return the prefer”.I’m trying to to find issues to enhance my site!I suppose its adequate to make use of some of your ideas!!
You made some nice points there. I did a search on the issue and found most individuals will approve with your blog.
I?¦ve been exploring for a little bit for any high quality articles or weblog posts in this kind of area . Exploring in Yahoo I at last stumbled upon this web site. Reading this information So i am happy to express that I’ve an incredibly just right uncanny feeling I came upon just what I needed. I such a lot for sure will make certain to do not forget this web site and provides it a look regularly.
hello there and thanks on your information – I have definitely picked up anything new from right here. I did however experience several technical points the usage of this web site, as I experienced to reload the site many times previous to I could get it to load correctly. I have been thinking about if your hosting is OK? Now not that I’m complaining, but slow loading cases times will often have an effect on your placement in google and could injury your quality ranking if ads and ***********|advertising|advertising|advertising and *********** with Adwords. Well I am adding this RSS to my e-mail and could glance out for much more of your respective fascinating content. Ensure that you update this again soon..
My brother recommended I might like this web site. He was entirely right. This post truly made my day. You cann’t imagine just how much time I had spent for this information! Thanks!
Utterly pent subject material, Really enjoyed reading.
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.
I was suggested this blog by my cousin. I’m not sure whether this post is written by him as nobody else know such detailed about my difficulty. You are incredible! Thanks!
thanks, perfect as usual
If you have Excel 2010 and are interested in capturing measures from one or multiple workbooks (without opening any of them) you could take a look at a project on Microsoft’s open source project website (CodePlex) for “Excel 2010 PowerPivot Measure reader “:
https://powerpivotmeasurereader.codeplex.com/
Thanks for the link Thomas
I’ve downloaded the archive but don’t know how to run the code – there’s no .exe file, only .js & I’m not familiar with json – Visual Studio required?
Perhaps I should just try Matt’s method!
Hope you see my message & can help.
thanks
Hi Matt,
this is really nice – great idea to create the “ready to copy” column.
Just wondered, why you didn’t give this job to your new friend:
let
Source = Excel.CurrentWorkbook(){[Name=”Tabelle1″]}[Content],
Filter = Table.SelectRows(Source, each not Text.StartsWith([CUBE_NAME], “$”)),
RemoveOtherCols = Table.SelectColumns(Filter,{“MEASURE_NAME”, “DATA_TYPE”, “NUMERIC_PRECISION”, “EXPRESSION”, “MEASURE_IS_VISIBLE”, “MEASUREGROUP_NAME”}),
FullFormula = Table.AddColumn(RemoveOtherCols, “FullFormula”, each [MEASURE_NAME]&”:=”&[EXPRESSION])
in
FullFormula
enjoy and stay queryious 🙂
mmmm, Power Query rather than VBA. Good Idea.
Hi Matt
Looking at trying your method, but the screen shot for DAX Studio is Excel 2013. Will this work in 2010?
thanks
I don’t se any reason why it won’t work with Excel 2010
Thanks for sharing Matt, this is likely to come in handy at some point.
One suggestion – have the table name in the Full formula (or it might be available in an existing column) so it is easily visible as to which table to add the formula to in the calculation area.