Excel 2007 Hangs When Trying to Edit an OLAP Cube Filter
Ok, it doesn't hang every time you try to edit an OLAP cube filter, but sometimes - it appears to. In reality, I've never seen it permanently hang - just kind of go away for a while. Here's the basic symptom that the business will report to you:
"Excel freezes (or hangs) when I try to change this filter"

Most of us have seen this at one point or another and shrugged it off as a busy time or processing is going on or there are cats clogging up the tubes, etc. Tonight, I finally decided to figure out what's causing it.
SSAS Cube Action: Cells Target type, URL Action type Example
Originally, we were charged with figuring out how to display SSAS cube measure descriptions via ToolTip in Excel 2007. If that's your plan, forget it - after some reading up on the interwebs, it appears that Excel doesn't even request the Description property. Additionally, if you want to add a description to Calculated Members, you have to hack it in (yuck).
So we went with a simple, albeit relatively crude (but effective), alternative - implementing a URL action for Cells so users can easily link out to a definition of the measure they're looking at.
Create a new action in your cube (Open up the cube definition, Actions tab) and configure similar to this:
Name: View Member Definition
Action Target
Target Type: Cells
Target object: All cells
Action Content
Type: URL
Action expression: "http://i.domain.com/doc/Defs.aspx#"
+ [Measures].CurrentMember.Name
Additional Properties
Invocation: Interactive
Description: View Member Definition
"View Definition Of " + [Measures].CurrentMember.Name + "..."
Caption is MDX: TrueWhen you're finished, it should look something like this:

For a possible way to implement the aforementioned Definitions.aspx, check out http://timlaqua.com/2009/03/scrolling-to-and-highlighting-anchor-target-via-javascript/ - which describes an early endpoint we used for this project.
Scrolling to and Highlighting Anchor Target via JavaScript
I implemented a SSAS cube action to link to a SharePoint page (URL Action) with the name of the measure contained in the cell the user fired the action from. The theory here is to have a page that contains a list of definitions for all measures (both real and calculated) in the cube. As we were flushing out this implementation, it was suggested that the page should scroll to the specified measure and highlight it in some way. The implementation of this using the CSS :target pseudo class is pretty straightforward - however we're a Microsoft shop and we absolutely have to support Internet Explorer 7 and Internet Explorer 8, so that's out.
Wierd Slice – Revenue for the Most Recent Hour in the Cube Across the Last 14 Days Sliced by Week
Well - there's two parts to this - one is to figure out the most recent hour in the cube that has data. Let's face it, it finishes as soon as it can - but that time may vary now and then. Then, for this particular report, we wanted to see the last seven days on one series and the previous seven days on another series. To do this, we just slice by two calculated measures. But this creates an odd dateset where the This Week column will have no data for the "Date Time" columns that actually belong to the Previous Week.
This isn't really a problem as in SSRS, you can simply define the Category Group for the Series in your chart (ya, I didn't mention that yet - this is all for a chart) as DatePart("w", Fields!DateTime) - which will group everything by the number of the given weekday and then you can just have your "This Week" and "Prevoius Week" series.
WITH MEMBER [Measures].[This Week] AS Aggregate ([Time].[Calendar Date].LastChild:[Time].[Calendar Date].LastChild.Lag(6) ,[Measures].[Revenue]) MEMBER [Measures].[Previous Week] AS Aggregate([Time].[Calendar Date].LastChild.Lag(7) : [Time].[Calendar Date].LastChild.Lag(13) ,[Measures].[Revenue]) SELECT NON EMPTY {[Measures].[Previous Week], [Measures].[This Week]} ON 0 ,NON EMPTY { [Time].[Date Time].[Date Time].MEMBERS * [Time].[24 Hour].[24 Hour].ALLMEMBERS } ON 1 FROM ( SELECT Tail( Filter( [Time].[24 Hour].[24 Hour].MEMBERS ,Sum([Time].[Calendar Date].LastChild,[Measures].[Revenue]) > 0 ), 1 ) ON 0 FROM (SELECT { [Time].[Calendar Date].LastChild : [Time].[Calendar Date].LastChild.Lag(13) } ON 0 FROM [Cube] ) )
And to top it all off - after seeing the chart for a while, nobody liked it (after all, it's a relatively abstract view of revenue) and we dumped it.
How to add a calculated measure (calculated field) to an Excel 2007 PivotTable with a SSAS data source
As it turns out, you can do it programatically as explained by Allan Folting here:
Microsoft Excel: Common Questions Around Excel 2007 OLAP PivotTables:
http://blogs.msdn.com/excel/archive/2008/02/05/common-questions-around-excel-2007-OLAP-PivotTables.aspx
And the parts that I have to keep looking up (I use my blog as a notebook for things I don't want to forget
:
Sub AddCalculatedMeasure() Dim pvt As PivotTable Dim strName As String Dim strFormula As String Set pvt = Sheet1.PivotTables("PivotTable1") strName = "[Measures].[Internet Sales Amount 25 %]" strFormula = "[Measures].[Internet Sales Amount]*1.25" pvt.CalculatedMembers.Add Name:=strName, Formula:=strFormula, Type:=xlCalculatedMember End Sub Sub AddCalculatedMember() Dim pvt As PivotTable Dim strName As String Dim strFormula As String Set pvt = Sheet1.PivotTables("PivotTable1") strName = "[Product].[Product Categories].[Bikes].[Mountain Bikes].[Mountain-100 Silver, 38 25 %]" strFormula = "[Product].[Product Categories].[Bikes].[Mountain Bikes].[Mountain-100 Silver, 38]*1.25" pvt.CalculatedMembers.Add Name:=strName, Formula:=strFormula, Type:=xlCalculatedMember pvt.ViewCalculatedMembers = True End Sub Sub AddNamedSet() Dim pvt As PivotTable Dim strName As String Dim strFormula As String Dim cbf As CubeField Set pvt = Sheet1.PivotTables("PivotTable1") strName = "[My Mountain Bikes]" strFormula = "[Product].[Product Categories].[Bikes].[Mountain Bikes].children" pvt.CalculatedMembers.Add Name:=strName, Formula:=strFormula, Type:=xlCalculatedSet Set cbf = pvt.CubeFields.AddSet(Name:="[My Mountain Bikes]", Caption:="Mountain Bikes") End Sub
He also mentions that you can expose these members to Excel Services 2007 by creating the new objects and then removing the VBA code - very useful article.
Dynamic MDX queries in TSQL
Say you want to run the same MDX query for each row in a given rowset. I needed to do this for alerting purposes, where there were different alert thresholds for different attribute values in a given dimension attribute. After struggling with passing a variable to the query argument of the OPENROWSET command, I finally found the documentation that clearly stated that the query argument CAN'T be a variable. Or a concatination of a string and a variable. I still don't understand why... but the suggested workaround is to construct a giant TSQL string and run it using the EXEC command.
Ok - but how do we get the results of the query? Basically, the only way to do this is to create a temporary table in the current scope and do an INSERT INTO that temp table in your giant TSQL query. It all ends up looking something like this:



