基于选定维成员的事实汇总

时间:2019-01-26 19:52:46

标签: ssas mdx mdx-query

如何添加总计列,如下图所示。

enter image description here

查询结构如下

WITH
    MEMBER [Measure].[Total Responses] AS [Measures].[Responses]

    MEMBER [Measure].[Option 1] as CoalesceEmpty([Measures].[Option1],0)
    MEMBER [Measure].[Option 2] as CoalesceEmpty([Measures].[Option2],0)
SELECT
{
    //Add Total Here for Below Dimension Members
    [Date].[Month].&[2018]&[2018-Q4]&[2018-09], //say Month 1
    [Date].[Month].&[2018]&[2018-Q4]&[2018-10], //say Month 2
    [Date].[Month].&[2019]&[2019-Q1]&[2019-01]  //say Month 5 
} ON COLUMNS,
NON EMPTY
{
    [Measure].[Total Responses],
    [Measure].[Option 1],
    [Measure].[Option 2]
} ON ROWS
FROM [Cube]

1 个答案:

答案 0 :(得分:0)

在下面的查询中,编辑标记为**

WITH
  MEMBER [Measure].[Total Responses] AS [Measures].[Responses]

  **MEMBER [Date].[Month].[AllMessages] AS AGGREGATE({[Date].[Month].&[2018]&[2018-Q4]&[2018-12],[Date].[Month].&[2019]&[2019-Q1]&[2019-01]})

  MEMBER [Measure].[Option 1] as CoalesceEmpty([Measures].[Option1],0)
  MEMBER [Measure].[Option 2] as CoalesceEmpty([Measures].[Option2],0)

SELECT
{
  **[Date].[Month].[AllMessages],
  [Date].[Month].&[2018]&[2018-Q4]&[2018-12],
  [Date].[Month].&[2019]&[2019-Q1]&[2019-01]
} ON COLUMNS,
NON EMPTY
{
  [Measure].[Total Responses],
  [Measure].[Option 1],
  [Measure].[Option 2]
} ON ROWS
FROM
  [Cube]