0

在此处输入图像描述我想计算各个类别的百分比,这是我的 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 个类别,例如“外部驱动因素”、“战略”、“业务运营和治理”。

我需要计算同一类别中不同颜色的百分比。例如,如果我们采用“外部驱动程序”,那么计算应该像
amber = 15/28 * 100、green = 5/28/*100 等,因为 28 是外部驱动程序的总和。请告诉我如何在 mdx 中执行此操作。

谢谢

4

1 回答 1

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]

结果

我不知道我是否正确阅读了您的尺寸,但也许您的成员应该看起来像:

with member [Measures].[Percent] as
 [Measures].[AGG_RATING Count] /
 ([DIM RATING STRINGS].[LABEL].CURRENTMEMBER.PARENT,
  [Measures].[AGG_RATING Count])
 , format_string = "percent"
于 2013-03-28T22:08:57.853 回答