Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Can MDX Case statement do this?


Can MDX Case statement do this?

Author
Message
Mike Austin-398977
Mike Austin-398977
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 177
All,

I have developed a cube that tracks the timeliness of certain steps in a business process. Steps are on time if the number of days between 2 dates is <= values that are stored in a table. The fact table for the cube is assigned a Timeliness dimension ID accordingly.

In addition, the users want to be able to play with the results by being able to dynamically enter a cutoff day value. To accommodate this, I have a column in the fact table, called "ElapsedDays" that is the difference between the two dates. My plan was to use this column with a parameter to re-calculate the timeliness dimension. The T-SQL logic would be as follows:

CASE
   WHEN ElapsedDays <= @parameter THEN 1 -- On time
   WHEn ElapsedDays > @parameter THEN 2 -- Late
   ELSE 3 -- Unknown
END AS TimelinessDimID

In essence, I want to substitute my new dimension values for the old ones.

Can this be done in MDX?

TIA,

Mike
robert.gerald.taylor
robert.gerald.taylor
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1319 Visits: 1398
Mike Austin-398977 (3/3/2014)
All,

I have developed a cube that tracks the timeliness of certain steps in a business process. Steps are on time if the number of days between 2 dates is <= values that are stored in a table. The fact table for the cube is assigned a Timeliness dimension ID accordingly.

In addition, the users want to be able to play with the results by being able to dynamically enter a cutoff day value. To accommodate this, I have a column in the fact table, called "ElapsedDays" that is the difference between the two dates. My plan was to use this column with a parameter to re-calculate the timeliness dimension. The T-SQL logic would be as follows:

CASE
   WHEN ElapsedDays <= @parameter THEN 1 -- On time
   WHEn ElapsedDays > @parameter THEN 2 -- Late
   ELSE 3 -- Unknown
END AS TimelinessDimID

In essence, I want to substitute my new dimension values for the old ones.

Yes, you can create a calculated member. Take a look at:

http://technet.microsoft.com/en-us/library/ms146017(v=sql.105).aspx
http://technet.microsoft.com/en-us/library/ms144841(v=sql.105).aspx

If you have the Adventure Works cube, you can try something like:
WITH MEMBER [Measures].x AS
CASE
WHEN [Measures].[Order Count] < 100 THEN 'Low'
WHEN [Measures].[Order Count] < 300 THEN 'Medium'
ELSE 'Large'
END
SELECT
{ [Date].[Calendar].[Month] } ON ROWS,
{ [Measures].[Order Count], [Measures].x } ON COLUMNS
FROM [Adventure Works];



Not exactly what you asked for -- but you should get the idea.

I hope this helps,
Rob
Mike Austin-398977
Mike Austin-398977
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 177
Thanks for your reply. I inadvertently left out the fact that the cube is going to be the source for reports surfaced in PowerPivot and PerformancePoint. My idea was that the report developers would implement the case statement in their filtering/retrieval of the cube's data. Can the MDX case statement be used this way?

My only other alternative is to add create 60 fact rows for each existing row, which creates its own set of problems...

TIA,

Mike
RonKyle
RonKyle
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1254 Visits: 3337
My only other alternative is to add create 60 fact rows for each existing row, which creates its own set of problems...


It's not clear to me why you'd do this, unless you mean in another fact table that would then of course have a different level of granularity. My sole caution is that the correct level of granularity for a fact table is crucial. If you don't have a clear grain and then violate it, your cube will produce incorrect data in certain cases.



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search