Thursday, May 24, 2007

Creating a running total with MDX

Today I had a task of creating a running total of the deposits and withdrawals on an account, but still being able to get the amount for months back in time, so doing a sum won't do it.

So I was up to creating a calculated member using some MDX-script.

My solution right now is to make a sum from the first member of my time dimension (2004-01-01) till the current member of the time dimension.
The syntax looks like this:
SUM(
[Date].[Date].[Year].&[2004].&[Quarter 1].&[200401]:[Date].[Date].CurrentMember, Measures.[Amount])


In my current application I only use the month level, so for now I rest my case with looking at the month level, however, it should be fairly simple to extend the script above to examine the CurrentMember level, that is check if it's at day, month, quater or year level and make the appropriate script.

MDX Contains-function

To my surprise a contains-function was found in the SQL Server books online (BOL). Great stuff right. The function was supposed to return wether or not a member was part of a set. I actually needed that functionality in one of my projects.

However, I found that the contains-function never made it to the release version, but in fact is still documented. At least in the first version of the BOL (the one installed with the Sql Server 2005 installation CDs). If you discover the same article in BOL you should update it with a newer version, which is found here:
http://msdn2.microsoft.com/en-us/library/ms166018.aspx

Friday, May 18, 2007

More issues regarding the calculations tab

As mentioned in the blog post http://frustrated-developer.blogspot.com/2007/02/application-exception-unexpected-error.html Analysis Services may throw an Application Exception when choosing the Calculation Tab.

Recently I discovered that in some circumstances the application may hang, when choosing the calculations tab, however the solution is exactly the same as the one mentioned in the blog post above. That is some version conflict in two dll-files (msmdlocal.dll and msmgdsrv.dll).