如何使用MDX获得百分比

时间:2015-06-01 08:24:18

标签: ssas mdx

我想在运行时间找到索赔的百分比 我知道可以使用计算的度量来实现,但我不知道该怎么做。请指导我如何找到索赔的百分比((行数/祖父)* 100)。

enter image description here

2 个答案:

答案 0 :(得分:1)

尝试以下内容:

WITH 
   MEMBER [Measures].[PercentageOfAll] AS
       [Tmp Claim Dim].[Claimno].CURRENTMEMBER
       /
      ([Tmp Claim Dim].[Claimno].[All])
   ,FORMAT_STRING = 'Percent';
SELECT 
    {[Measures].[Tmp Claim Dim Count],
     [Measures].[PercentageOfAll]} ON 0,
     [Tmp Claim Dim].[Claimno].MEMBERS ON 1 
FROM [ACOE PI];

如果您希望上述内容仅应用于度量[Tmp Claim Dim Count],那么您可以在新度量中使用具有此度量的元组:

WITH 
   MEMBER [Measures].[PercentageOfAll_ClaimCnt] AS
      ([Tmp Claim Dim].[Claimno].CURRENTMEMBER, [Measures].[Tmp Claim Dim Count])
       /
      ([Tmp Claim Dim].[Claimno].[All], [Measures].[Tmp Claim Dim Count]) 
   ,FORMAT_STRING = 'Percent';
SELECT 
    {[Measures].[Tmp Claim Dim Count]} ON 0,
     [Tmp Claim Dim].[Claimno].MEMBERS ON 1 
FROM [ACOE PI];

答案 1 :(得分:0)

你可以适应并试试这个:

WITH 
   MEMBER [Measures].[Percentage] AS
   [Measures].[line count]/
   ([Measures].[grandtotoal]), 
   FORMAT_STRING = 'Percent';
SELECT 
{[Measures].[Percentage]} ON COLUMNS, 
FROM [yourcube]