2013-03-27 74 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