将Total列添加到MDX

时间:2009-11-24 10:14:12

标签: sql sql-server ssas mdx

我有以下查询,它提供了一个摘录(我将它从我的多维数据集中放入CSV)。

我希望将列中所有NRx的总和显示为第一列NRx,其余的NRx列应该像现在一样显示。我尝试为此添加SUM (Measures.NRx),但它无法正常工作

如何获得Total NRx列?

SELECT
NON EMPTY
CrossJoin
(
    [Time Period].[Calendar].[Cycle Dt],
    {
        [Measures].[NRx]
    }
)
 ON COLUMNS,
NON EMPTY
{(
       [Prescriber].[Prescriber Name].[Prescriber Name].Members
    ,  [Prototype Alignment].[Tier Code].[Lilly Tier Code].Members
    ,  [Prototype Alignment].[Territory Name].[Territory Name].Members
    ,  [Prototype Alignment].[District Name].[District Name].Members
    ,  [Prototype Alignment].[Division Name].[Division Name].Members
    ,  [Prototype Alignment].[Area Name].[Area Name].Members
    ,  [Market Product].[Product Group Nbr].[Product Group Nbr].Members
    ,  [Market Product].[Product G Name Name].[Product G Name Name].Members
)}    DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM 
( 
    SELECT 
    ({
        [Prescriber].[Ims Prescriber Id].&[011111]
    }
    ,
    {
        [Time Period].[Cycle Dt].&[2008-10-03T00:00:00],
        [Time Period].[Cycle Dt].&[2008-10-10T00:00:00],
        [Time Period].[Cycle Dt].&[2008-10-17T00:00:00],
        [Time Period].[Cycle Dt].&[2008-10-24T00:00:00],
        [Time Period].[Cycle Dt].&[2008-10-31T00:00:00],
        [Time Period].[Cycle Dt].&[2008-11-07T00:00:00],
        [Time Period].[Cycle Dt].&[2008-11-14T00:00:00],
        [Time Period].[Cycle Dt].&[2008-11-21T00:00:00],
        [Time Period].[Cycle Dt].&[2008-11-28T00:00:00],
        [Time Period].[Cycle Dt].&[2008-12-05T00:00:00],
        [Time Period].[Cycle Dt].&[2008-12-12T00:00:00],
        [Time Period].[Cycle Dt].&[2008-12-12T00:00:00],
        [Time Period].[Cycle Dt].&[2008-12-19T00:00:00],
        [Time Period].[Cycle Dt].&[2008-12-26T00:00:00],
        [Time Period].[Cycle Dt].&[2008-12-26T00:00:00]        
    }
)  ON COLUMNS 
FROM [Mart]
)    CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, 
    FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

1 个答案:

答案 0 :(得分:1)

如果您在SELECT查询之前使用以下内容创建计算成员,该怎么办:

SUM([Measures]。[NRx],[Time Period]。[Calendar]。[Cycle Dt])?

然后就这样做:

选择 NON EMPTY [MYCALCMEMBER_SUM] * CrossJoin([时间段]。[日历]。[循环Dt],{[测量]。[NRx]})在列上,