Microsoft has released the first for SQL Server 2008 cumulative update package. Among other issues, it fixes the SSAS bug with requesting measures with mixed aggregation functions which I previously reported.
Archive for month: September, 2008
Issue: You use Excel as an OLAP browser connected to an SSAS cube. You’ve defined the name of the Month attribute in the Date hierarchy in the format MMM-YYYY. While months are sorted in an ascending order in Excel, descending sorting doesn’t work; or rather Excel sorts them as strings. That’s because Excel interprets these captions as strings instead of dates even if you set the Value property of the Month attribute to a field of DateTime type.
Workaround: You can use the Excel custom sorting feature as a workaround while waiting for Excel to become a better OLAP citizen:
- Connect to the cube and select the Month attribute to get all months displayed in Excel. Select all month cells.
- Click the Excel Office Ribbon button.
- In the Popular tab, click the Edit Custom Lists button.
In the Custom Lists dialog box that follows, click Import button to create a new custom list for the dates in the format MMM-YYYY. Click OK
As you can see, there is a custom sorting list for months in the format MMM, so descending sort will work if the month captions are in MMM format. However, the end user won’t be able to tell the months apart if the user requests only the Month attribute on the report. So, you kind of have to pick up your own poison.
Scenario: You need to personalize the captions of calculated members or/and KPIs of an SSAS cube. For example, a solution vendor may need to deploy a cube to multiple clients. Instead of maintaining separate cube definitions, the vendor may prefer to change the captions of certain calculated members and KPIs per client. There wasn’t a good story in SSAS 2005 about such requirements. In SSAS 2008, there are at least two techniques to tackle cube personalization.
First, SSAS 2008 introduces a new Caption property to calculated members and KPIs, which Chris Webb has already written about. Vidas Matelis has provided great examples of using the Caption property. Thanks to this enhancement, you can keep the names of calculated members and KPIs the same but change only their captions. This is the good news.
What if you need to make definition changes programmatically, such as to check the type of the client and change captions accordingly? Well, unfortunately the Caption property is not available in the AMO library as it has not been added to the KPI class. What’s worse is that the CREATE KPI statement doesn’t actually add the KPI definition to the KPIs Collection so you cannot programmatically change the caption by enumerate the AMO Kpis collection and update the KPI definition. To make the story short, the only way I’ve found to update the KPI caption is to update the cube MDX script (Cube.MDXScripts AMO collection). This forces you to resort to search and replace text inside the cube script. Sigh… The following code shows how to use AMO to connect to the cube and change the cube MDX script.
void Main(string args)
Server server = new
Database database = server.Databases[“<database name”];
Cube cube = database.Cubes[“<cube name>”];
// assume KPIs are defined in the cube default script
MdxScript mdxScript = cube.MdxScripts;
Command command = mdxScript.Commands;
// search and replace captions in the command.Text
// command.Text = …
The second personalization option is the new Personalization Extension mechanism in the SSAS 2008, which I personally haven’t tried out. Microsoft has provided a sample here. A custom personalization extension is a .NET code that is deployed to the server. It lets you create user-specific session-level calculated members and KPIs without having to change the cube definition. The extension changes are transient and disappear when the user’s session ends.