Tuesday, January 13, 2009

Complicated WHERE Clause

Goal:
The filter is as followed.

_All Releases
Overflow
Release 1
Release 2
Release 3
Release 4
Release 5

When user selects _All Releases, the filter should only filter out Overflow. When user selects Overflow, the filter should only take Overflow. When user selects Release 1, the filter should take Iteration 1 through 9. When user selects other releases, the filter should take the selected release.

Solution:
((@Release='_All Releases' AND (i.[Iteration Path] <> '\Cobalt Product Backlog\Overflow'))OR (@Release = 'Overflow' AND i.[Iteration Path] = '\Cobalt Product Backlog\Overflow')OR (@Release <> '_All Releases' AND @Release <> 'Overflow' AND (i.[Iteration Path] LIKE '\Cobalt Product Backlog'+ CASE @Release WHEN 'Release 1' THEN '\Iteration%' ELSE '\'+@Release+'%' END)))

Thanks to the following post:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=54046

Monday, January 5, 2009

MDX Using SUM() to Convert A Query to A MDX Statement

Using SUM() function allows you to convert a regular MDX query to a MDX statement. So it can be used in for calculated member. The post below talks about it:

http://social.msdn.microsoft.com/forums/en-US/sqlanalysisservices/thread/7c2b58e1-4b20-4f8b-866f-7c328add916d/

If more than one set if required to slice the data, wrap the sets and measure with SUM() function. It's like using a tuple that allows slicing by sets instead of members. See example:

SUM(([Measures].[_Microsoft_VSTS_Scheduling_CompletedWork], [WorkStreams], [Work Item].[System_WorkItemType].&[eScrum Sprint Task]))

MDX Dynamic Sets

Interesting stuff
http://www.sqljunkies.com/WebLog/mosha/archive/2007/08/24/dynamic_named_sets.aspx

MDX Iterative Calculations

I found this topic interesting. Will look at it later:

http://social.msdn.microsoft.com/forums/en-US/sqlanalysisservices/thread/84a04c2c-a758-4092-9ef7-74f51116cbb0/

Wednesday, December 31, 2008

How to Join the Results of Multiple MDX Queries on Date Demension

I need to get a datasest and combines multiple MDX query's results. I know using stored procedure can probably solve the problem. But I don't have write access to the Cubes.

Solution:
.......Still working on it......

Monday, December 29, 2008

Use IN Statement for Multivalue Parameters

When use IN statement in the WHERE clause for multivalue parameters, the parameters needs to be in parentathes. E.g.

a.[Microsoft_VSTS_Common_Priority] IN (@Priority)

Friday, December 12, 2008

SQL: Removes the Time Portion of a DateTime Value

I encountered a situation that I need to get only the Date portion of a Datetime value. After some digging, I found a post that has exactly what I want. A SQL expression, dateadd(dd,0, datediff(dd,0,@DateTime)), was used to give just the date portion. I'm not quite sure about why it did the trick. But it worked for me.

The original post is at:
http://weblogs.sqlteam.com/jeffs/archive/2007/01/02/56079.aspx