MDX的百分比计算

时间:2011-08-10 14:39:06

标签: ssas mdx olap

我是MDX查询的新手,我正在尝试在每行中添加百分比。以下代码:

SELECT {[Measures].[Client Interventions Count]* [Dim Intervention Attendance].[Attended].Children} ON COLUMNS,
[Dim Date].[Calendar].[Month Name] ON ROWS
FROM [Client Intervention]

获得结果:

enter image description here

如何对每一行进行计算?例如,2007年11月第一行,总客户干预计数= 68,因此百分比计数应为57/68%

任何想法?感谢

1 个答案:

答案 0 :(得分:0)

使用计算成员 - 您可以找到几个示例here。查询的想法如下:

WITH MEMBER [Dim Intervention Attendance].[Attended].[%] AS
    ( [Dim Intervention Attendance].[Attended].[Attented],
       [Measures].[Client Interventions Count] )
  / ( [Dim Intervention Attendance].[Attended].[Not Attented], 
      [Measures].[Client Interventions Count] )

SELECT  
  [Measures].[Client Interventions Count] 
   * { [Dim Intervention Attendance].[Attended].[%], 
       [Dim Intervention Attendance].[Attended].Children } ON COLUMNS,

  [Dim Date].[Calendar].[Month Name] ON ROWS

FROM [Client Intervention