How can I display the MDX generated by Excel 2007 when using a pivot table? - excel-2007

Pretty much what the title says. Is it possible to show the MDX that is sent to OLAP source when using a pivot table in Excel 2007?

You can download the OLAP Pivot Table Extensions from the codeplex site( http://olappivottableextend.codeplex.com/)
Install it.
You can then right click and see the OLAP query.
Regards,
Ambarish

I was curious to see the MDX generated by a pivot table in Excel also. Apart from imputing MDX manually I couldn't see a way to see the MDX after a user has selected and filtered etc.. on the pivot table itself.
But I found a quick vba snippet here
PivotTable.MDX
All I did was ALT + F11 to bring up the VBA window
Insert a userform like so
Click inside the textbox inside the userform and change these two settings in the properties window
Multiline - True
Wordwrap - True
Paste in the code below
Sub CheckMDX()
Dim pvtTable As PivotTable
Set pvtTable = ActiveSheet.PivotTables(1)
UserForm.TextBox.Value = pvtTable.MDX
UserForm.Show
End Sub
Make sure your Pivot Table is the active sheet (i.e have the worksheet open on the pivot table clicked in a cell).
Press the run button and a userform should pop up like so where you can copy out the MDX text.
This was on Excel 365. Hope this helps.

If you have profiler you could set up an Analysis Services trace and catch it on the way, or do you need to see it without executing it?

While the OLAP Pivot Table Extensions are still available for Excel 2013, you can no longer right-click on the table and view the MDX. This is yet another example of MIcrosoft going out of their way to make life more difficult for end-users and developers. The ability to view MDX for the current PivotTable selections should be built into Excel. It's not because Microsoft's developers either were too careless to give such a critical thing priority or because the powers that be saw a potential for an add-on product. Regardless, it's an example of why they are often hated. Over the years I can't even count all the hours of life I've lost outside the normal workday because the incompetent or malevolent behavior of Microsoft's manager, developers... But what other toolset can do what Excel and SSAS do? It's not an easy thing to replace so we have to deal with their crippled tools.

There is a free web based pivot table tool called WebPivotTable which can connect to SSAS cube directly and display each MDX statement for teh current PivotTable selections. It has all functions as Excel but with more intuitive user interface. In MDX windows, you can even test your own MDX statement and get results displayed in table and charts.
Here is Demo and Documents.

Related

Dictionary vs pivot Table and some office issues

In company when I currently work we have big issue with MS excel stability, hence my question below.
Recently I just learned about excel Dictonary code.
I know pivot tables and how they work.
sadly the issue is not with pivot themselves but with excel. (IT dept. is working on the issue for 3 weeks now, and we dont know when / if they gonna fix it)
Hence my big ask for thi community:
I would need a userform working with the dictonary.
What I would need is to create a code that could work as pivot table but using dictonaries (since theoreticaly they are faster and are outside of VBA / excel basic in-build option)
so?
Can some1 help in creating such code?
Is this the right option?
I would like to see a userform where I can choose my Table(ctrl+T) headers to choose by which header i want to sum values up, and ofc I would have to be able to choose a column by which the dictonary summing is working on.
Thank you both for answering.
Lets start then.
I watched ExcelMacroMastery videos regarding dictionaries,
In this example, he used them to make a basic sum exactly like the basic functionality of Pivot table.
So since that's the basic use where I work I wish to have a dictionary macro from which I can choose the column by which I get unique values and 2nd column with a sum from the second provided column from a table.
the issue is: if I show any file or any example this could result in macro working for this specific case, and I would like it to be able to choose by Table's (CTRL+T) headers for the unique values and to use some way(like a dropdown menu) to choose the column by which the sum can happen.
This instability is due to 32 bit office suite 365 working n 64 bi PCs/ laptops and recent company update made it even worse, now there is an issue with even basic save file option.
Not to mention excel crashing for no apparent reason.
So to sum up,
I need dictionaries to kinda step up and replace basic summarizing functionality of an pivot table.
or to replace this non pivot way:
use unique function to determine unique values from specified column (non-table object sadly)
Use sumif or sumoifs function to summarize the specified amount/value for that unique list.
//EDIT:
I kinda found what I was looking for thus the edit.
Im showing the link to the file I wish to change a bit:
https://app.monstercampaigns.com/c/s0iavndiopijkrar8ghp/
to this file I wish to add a user form by which the headers of the report will be chosen from source data, and by which the sum will occur.

VBA AddDataField CubeFields - Error 1004

I'm stumped...been building a PowerPivot sales report over the past few months and teaching myself VBA and DAX along the way. My report has several pre-configured views that can be chosen by VBA buttons, which work completely fine until you close the workbook and re-open it. Every time the workbook is opened for the first time - the VBA code errors out on the first AddDataField CubeFields line of code. It's as if excel does not pre-calculate the measure I am trying to add.
If I manually remove/add a value in the pivot table and then run the VBA code, it runs flawlessly. If I open PowerPivot manage data window and then close it, the VBA code runs perfectly fine. Something about manually changing values in the pivot table or simply opening the PowerPivot data tab, prompts Excel to pre-calculate all measures. Here is the exact line of code that gets hung up every time:
Worksheets("Dealer Install Sales").PivotTables("PivotTable1").AddDataField Worksheets("Dealer Install Sales").PivotTables( _
"PivotTable1").CubeFields("[Measures].[Sum of INVOICE_QTY]"), _
"PIECES"
How do I force excel to automatically calculate all measures upon opening the workbook?
I think what might be going on is the behaviour described in this joy-of-data blog post.
To paraphrase, a measure used in a pivot table which was created outside it, is "forgotten" in certain circumstances. A solution is to create a new measure within the pivot table field list (right click in field list and add measure), which simply references the original measure, e.g. =[measure name].
In your code, refer to the new name of measure, and when you do this, the data model should be stimulated into returning the value of the original measure, instead of falling over.

Exporting SQL Server data to Excel

We work with a lot of data at my job, and I want to try and find a way to limit the amount of copying from SSMS to an Excel sheet that goes to the client.
What I want to be able to do, using SSIS if possible or any other possible way (Maybe power query?), is to copy the data pulled via a SQL query to an Excel workbook sheet.
For example, I want to do a count on the amount of members by state, I'd have the query run and the results copied to the sheet called "State" in the Excel work book.
Example code:
SELECT C.State, COUNT(*) as Count
FROM [dbo].Input I
Join Cassresults C on C.ID = I.ID
group by C.State
order by Count desc
The Excel workbook will never change for the client. The only thing that may change are the queries, but those are easily updated.
Is there a way to actually do this or am I nuts for thinking so? I hope I explained it well enough.
SSAS, SSIS, PowerQuery, PowerBI, Excel PowerPivot, SSRS, and Excel Data Querys all are geared for this type of use. I would definitely NOT recommend VBA as your users will constantly get a security warning and it is more complex than needed.
For Excel probably a good starting location go to the data tab and click "From Other Sources" and check out the different source types. From Micrsoft Query gives you the ability to write a query or copy from SSMS.
The only thing is will Data Sources Change? If so every workbook you create and distribute will the become obsolete and need to be changed. SSRS is a good choice to allow users to grab the report (and export to Excel) that they need.
When doing SSAS it is great as well but start with PowerPivot in Excel, again data connections move Sharepoint data connection library is a way to combat that.
This is like a BI and reporting design question and you will get a plethora of answers.

pivot report excel 2007 on ssas

I am very new to this. I built a pivot report (excel 2007) on ssas. It has data, rows, columns. And columns has hierarchy likes day-month. Now I want to send this report to a customer, so he can view it by himself and expand the hierarchy as he likes. But he can only see the contents as I saved the report. E.g. I saved it as month hierarchy and he can only see the monthly figures and can not expand the hierarchy to day. What should I do? The customer has no access to the ssas data source.
Thanks
N. Z
The pivot report needs some kind of a datasource.
Whether it is the cell values of an excel sheet or the connection to the SSAS Cube, it's fine but in order to do drillthrough actions a datasource is obligatory.
There are various workarounds for this:
Export all the aggregated data that you want your user to view to a new spreadsheet and make a simple pivot table based on that sheet.
Setup a role in SSAS and give your user the specific permissions you want him to have on the data. This requires the knowledge of some MDX but simple stuff is autoconfigured. You can then give your user access to the datasource inside of the excel.
Set up a sharepoint installation which is part of the BI (this is a bit of an overkill) and provide your users with dashboards of reports using PerformancePoint Services.
I really don't think that you can browse the data without data(datasource)!!! I would be glad to be proven wrong.

Access Database

I need help in creating an query interface with access database.
In brief, with this query interface I want to see calculated future dates for different steps of a process based on the date the process actually started.
The future dates will always be at a fixed number of days after the start date. I hope I am able to explain this in an understandable manner.
I was thinking of using access forms? Please help me in this. I am not sure of how to proceed with this.
If your data is already in MS Access, then using Access Forms would be your easiest method of displaying that data. If the data is elsewhere, such as in Sql Server, you may be better suited in the long run using a different display technology.
That being said, to select a number of dates, as you would do in Access, you can use the Date Add function. If you had a table Processes with a column StartDate, you could use the query
SELECT *, DateAdd("d",5,StartDate) as "5 Days", DateAdd("d",36,StartDate) as "36 Days"
FROM Processes
to generate a record set to bind your form to. Binding that query to a new form is easy. You just need to change the record source by:
Right click anywhere blank in your new form
Select Properties
Change to the data tab
Click the button next to the text box labeled "Record Source"
Build your query using the built in editor (or, to paste the given SQL, right click in the designer view and select SQL view, then paste)
Close the query building dialog and use your new fields. You can drag them from the field list onto the design surface.