Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

MDX Help Same Time Period

 
   Database Help (Home) -> OLAP RSS
Next:  Incrementing Invoice Number  
Author Message
Greg

External


Since: Mar 20, 2008
Posts: 11



(Msg. 1) Posted: Tue Dec 30, 2008 2:21 pm
Post subject: MDX Help Same Time Period
Archived from groups: microsoft>public>sqlserver>olap (more info?)

This is tough finding MDX help. I have written an MDX query, and I am not an
expert but could use some help. It shouldn't be complicated, but I can't
figure it out. Please help. I have provided the code.

Issue: In my WHERE statement, I am filtering for 11 months, but the
parallelperiod is for the entire year. I need the parallelperiod to compare
the same period (11 Months). The Date Range can be hardcoded, as I can build
dynamic MDX in SSRS

Purpose: To be used by Reporting Services. Need to compare the same exact
time periods but for the previous year.


EXAMPLE MDX:

WITH MEMBER [Measures].[Margin] AS ([Measures].[Sale Amt - Shipped
Fact]-[Measures].[Cost Amt - Shipped Fact]), FORMAT_STRING = "Currency"
MEMBER [Measures].[LYMargin] As
(
PARALLELPERIOD(
[Shipped Time].[Year - Quarter - Month - Date - Date Time - Is
Holiday - Is Weekday].[Year]
, 1
, [Shipped Time].[Year - Quarter - Month - Date - Date Time - Is
Holiday - Is Weekday].CurrentMember)
,[Measures].[Margin]), FORMAT_STRING = "Currency"

MEMBER [Measures].[Cost] AS ([Measures].[Cost Amt - Shipped Fact]) ,
FORMAT_STRING = "Currency"
MEMBER [Measures].[LYCost] AS
(
PARALLELPERIOD(
[Shipped Time].[Year - Quarter - Month - Date - Date Time - Is
Holiday - Is Weekday].[Year]
, 1
, [Shipped Time].[Year - Quarter - Month - Date - Date Time - Is
Holiday - Is Weekday].CurrentMember)
,[Measures].[Cost]), FORMAT_STRING = "Currency"
MEMBER [Measures].[CostPct] AS (IIF([Measures].[LYCost] IS NULL OR
IsEmpty([Measures].[LYCost]) OR [Measures].[LYCost] = 0, NULL,
([Measures].[Cost]-[Measures].[LYCost])/[Measures].[LYCost])), FORMAT_STRING
= "Percent"
MEMBER [Measures].[CostPctTtl] AS
( [Measures].[Cost]/( [Measures].[Cost],
Axis(1)(0)(Axis(1)(0)).Dimension.CurrentMember.Parent) ), FORMAT_STRING =
"Percent"

SELECT
NON EMPTY {
[Measures].[Cost],
[Measures].[LYCost],
[Measures].[CostPct],
[Measures].[CostPctTtl],
[Measures].[Margin],
[Measures].[LYMargin]} ON COLUMNS,
NON EMPTY {
([Product Dimension].[Department - Class - Sub Class -
Category].[Department])
*

[Shipped Time].[Year].[Year].[Calendar 2008] } ON ROWS
FROM [JBI Warehouse MF]
WHERE ([Shipped Time].[Month].[Month].[January 2008]:
[Shipped Time].[Month].[Month].[November 2008])

 >> Stay informed about: MDX Help Same Time Period 
Back to top
Login to vote
dpuri

External


Since: Nov 19, 2008
Posts: 3



(Msg. 2) Posted: Tue Dec 30, 2008 5:59 pm
Post subject: Re: MDX Help Same Time Period [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Looks like the multi-select problem discussed in this blog entry:

http://sqlblog.com/blogs/mosha/archive/2005/11/18/writing-multiselect-fr
iendly-mdx-calculations.aspx
>>
Writing multiselect friendly MDX calculations

One very common problem with authoring MDX calculations historically has
been the behavior of these calculations when the user who browses the
cube selects multiple members in the slicer as opposed to single one.
...
>>


So, for your specific query which has multi-select for months, you might
try something like:

WITH MEMBER [Measures].[Margin] AS ([Measures].[Sale Amt - Shipped
Fact]-[Measures].[Cost Amt - Shipped Fact]), FORMAT_STRING = "Currency"
MEMBER [Measures].[LYMargin] As
Sum(existing [Shipped Time].[Month].[Month].Members,
(
PARALLELPERIOD(
[Shipped Time].[Year - Quarter - Month - Date - Date Time - Is
Holiday - Is Weekday].[Year]
, 1
, [Shipped Time].[Year - Quarter - Month - Date - Date Time - Is
Holiday - Is Weekday].CurrentMember)
,[Measures].[Margin])), FORMAT_STRING = "Currency"

MEMBER [Measures].[Cost] AS ([Measures].[Cost Amt - Shipped Fact]) ,
FORMAT_STRING = "Currency"
MEMBER [Measures].[LYCost] AS
Sum(existing [Shipped Time].[Month].[Month].Members,
(
PARALLELPERIOD(
[Shipped Time].[Year - Quarter - Month - Date - Date Time - Is
Holiday - Is Weekday].[Year]
, 1
, [Shipped Time].[Year - Quarter - Month - Date - Date Time - Is
Holiday - Is Weekday].CurrentMember)
,[Measures].[Cost])), FORMAT_STRING = "Currency"
...


- Deepak

Deepak Puri
Microsoft MVP - SQL Server

*** Sent via Developersdex http://www.developersdex.com ***

 >> Stay informed about: MDX Help Same Time Period 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
4 weekly period within time dimension - Is it possible to generate a four weekly period within the time dimension? Or do you happen to know the accurate name of the attribute which does this within the server generated time?

Parallel Period problems - Hi all: I have a question/problem and I am hoping someone can point me in the right direction. I worked on the problem all day to no avail, and I googled endlessly without an answer. On the bright side, I learned quite a bit today. I have a cube with...

Parallel period combined with year to date - First let me say that I'm a complete novice when it comes to MDX. I am trying to write a query that gets the value of year to date to a specific month, but in the previous year. So far we have produced queries that get the year to date to a specific...

time dimension - Hi, I got inventory fact table, which I need to view by a time dimension. Problem is, its data is not on a single granularity: For the past two weeks, I got on a daily level; beyond that, weekly level, and at some point beyond that, monthly. I need to ti...

Time dependent Dimension - i have a dimension named 'CUSTOMER CLASSIFICATION' which depends upon the sales of the customer when the sales increases class changes for e.g from A to C it means the customer can have more then one class depending upon sales I have to maintained the....
   Database Help (Home) -> OLAP All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]