2013-03-27 48 views
0

enter image description here我想計算個別類別的百分比,下面是我的mdx代碼。計算MDX中各個類別的百分比

WITH 
MEMBER [Measures].[Individual_Total] AS ([DIM RATING STRINGS].[LABEL]*[Measures].AGG_RATING Count]) 

SELECT 
    NONEMPTY { 
    [Measures].[AGG_RATING Count],[Measures].[Individual_Total] 
     } ONColumns, 

    ([DIM STRUCTURE].[PARENT CODE].&[M01]&[M]:[DIM STRUCTURE].[PARENT CODE].&[M11]&[M], 
    [DIM TAILORING].[TAILORING_LABEL].[TAILORING_LABEL], 
    {[DIM RATING STRINGS].[LABEL].[LABEL],[DIM RATING STRINGS].[LABEL]} 

) onrows 


FROM [Cube] 

這裏是輸出

在此輸出中,我們有4個類別,如「」外部驅動,stretegy,經營和管理。

我需要計算同一類別中不同顏色的百分比。 例如,如果我們採用「外部驅動程序」,則計算應該類似於
琥珀色= 15/28 * 100,綠色= 5/28/* 100等,因爲28是外部驅動程序的總和。 請告訴我如何在mdx中做這件事。

感謝

回答

0

在這裏,您可以與我的解決方案相比,它會給你父的百分比。

with 
member [Measures].[Percent of parent] as 
([Measures].[Order Quantity])/
([Product].[Product Categories].currentmember.parent, 
[Measures].[Order Quantity]) 
,format_string = "percent" 

SELECT 
{([Measures].[Order Quantity]), 
([Measures].[Percent of parent])} ON COLUMNS, 
{[Product].[Product Categories].[Category].&[3]} * 
{[Product].[Subcategory].[Subcategory].Members} * 
{[Product].[Style].[Style].Members} * 
{[Product].[Product].members} 
ON ROWS 
FROM [Cube] 

Results

我不知道如果我正確地讀出你的尺寸,但也許你的成員應該是這個樣子:

with member [Measures].[Percent] as 
[Measures].[AGG_RATING Count]/
([DIM RATING STRINGS].[LABEL].CURRENTMEMBER.PARENT, 
    [Measures].[AGG_RATING Count]) 
, format_string = "percent" 
+0

感謝,它的工作原理:) – user999896 2013-03-31 09:05:55