运行总计仅涵盖具有数据的单元格范围

时间:2012-03-13 14:34:39

标签: ssas mdx

使用图示的模型

请注意,并非所有DimB成员都显示,因此DimA的总数大于显示的DimB的总和,请忽略此):

查询显示(月,收入)0,(dima,dimb)从多维数据集1开始 enter image description here

我想在创建计算成员时提供一些帮助,该成员将计算“月份”中的“运行总数”(不是实时维度)。

早些时候我正在使用这个,但在很多层面都错了:

[Measures].[Accumulated Revenue] = 
IIF(
        ([DimMonths].[Months].CurrentMember,[Measures].[Revenue]) = 0
    AND ([DimMonths].[Months].CurrentMember.NextMember,[Measures].[Revenue]) = 0
    ,
    IIF(
        AGGREGATE({
            [DimMonths].[Months].CurrentMember :
            [DimMonths].[Months].Parent.LastChild 
        },[Measures].[Revenue]) = 0
        ,
        NULL
        ,
        Aggregate( {
            [DimMonths].[Months].Parent.FirstChild : 
            [DimMonths].[Months].CurrentMember.PrevMember
        }
        ,[Measures].[Revenue])
        )
    ,
    Aggregate( {
        [DimMonths].[Months].Parent.FirstChild : 
        [DimMonths].[Months].CurrentMember
        }
    ,[Measures].[Revenue])
)

1 个答案:

答案 0 :(得分:2)

听起来像是一个“范围任务”的工作。基本上,使用范围分配,您可以沿[Member_DimA_01]切片覆盖计算度量的值,以便这些值代表运行总计而不是子项之和。

Here's a good tutorial from Chris Webb on scoped assignments to help get you started...

编辑:这是运行总计算的模板......

WITH 
SET [Months] AS
    {
        [Date].[Calendar Month].&[2011 - Jan]
        :
        [Date].[Calendar Month].&[2011 - Dec]
    }
MEMBER [Measures].[Running Total] AS
    SUM(
         {
            [Date].[Calendar Hierarchy].[Calendar Month].&[2011 - Jan]
            :
            [Date].[Calendar Hierarchy].CurrentMember
         }
        ,[Measures].[Revenue]
    )
SELECT  
    NON EMPTY{
        [Months]
    } ON 0,
    NON EMPTY{
        [DimA].[Member].Allmembers *
        [DimB].[Member].Allmembers
    } ON 1
FROM
    [<<cube name>>]
WHERE
    [Measures].[Revenue Running Total]