dbTalk Databases Forums  

MDX syntax problem

microsoft.public.sqlserver.olap microsoft.public.sqlserver.olap


Discuss MDX syntax problem in the microsoft.public.sqlserver.olap forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
user
 
Posts: n/a

Default MDX syntax problem - 08-03-2005 , 03:03 AM






Hi,

I have some difficulties with this MDX query.

I have a cube Sales, with the following dimensions :

Dimension : Period (All),Year,Month
Dimension : Custommers parent-child (All, .....)
Dimension : Stores (All),Store code

and the following measures :

- sales type 1,
- sales type 2,
- profit,
- profit rate (calculated member)
-> profit rate = profit/([sales type 1]+[sales type 2])

The end-user select in drop-down list
- a customer
- a beginnig period
- a ending period

I want to display a table
- Stores on rows
- profit, sales and profit rate details on columns by month and a sum over
the period

like this :

All period 01/05 02/05 03/05 04/05 05/05
--------------------------------------------------------------
store1 sales | 6000 1000 1000 1000 2000 1000
profit | 600 100 100 100 200 100
profit rate | 10% 10% 10% 10% 10% 10%

store2 sales |
profit |
profit rate |
......... |
storeN sales|



WITH

MEMBER [Measures].[sales] AS
'Measures.[sales type 1] + Measures.[sales type 2]'

MEMBER [Measures].[sum_profit] AS
'Sum(
{
[Period].[Year].&[2005].&[1]:[Period].[Year].&[2005].&[6]
},
Measures.[profit])'

MEMBER [Measures].[sum_sales] AS
'Sum(
{[Period].[Year].&[2005].&[1]:[Period].[Year].&[2005].&[6]}
,
Measures.[sales]
)'

MEMBER [Measures].[rate] AS
'Measures.[sum_profit] / Measures.[sum_sales]',
FORMAT_STRING = 'Percent'

MEMBER [Period].[All Period] AS
'Iif(Measures.CurrentMember.Properties("Caption") <> "profit",
Iif(Measures.CurrentMember.Properties("Caption")) <> "profit rate",
[Measures].[sum_sales],
[Measures].[rate]
),
Measures.[sum_profit])'

Select
{
[Period].[All Period],
[Period].[Year].&[2005].&[1]:[Period].[Year].&[2005].&[6]
}
ON Columns,

Non Empty CrossJoin(
Stores.[Store code].Members,
{Measures.[sales], Measures.[profit], Measures.[profit rate]}
) On Rows
From Sales
Where {Custommers.&[4098]}

The problem :
The value of member ([All Period],Measures.[Sales]) is twice too large ??

Many thanks for your help.

Damien



Reply With Quote
  #2  
Old   
Deepak Puri
 
Posts: n/a

Default Re: MDX syntax problem - 08-03-2005 , 05:31 PM






Is the value of member ([All Period],Measures.[Profit]) also twice too
large; and what is the member name at the "All" level of the [Period]
dimension?


- Deepak

Deepak Puri
Microsoft MVP - SQL Server

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

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.