MDX计算用于将两个度量的乘积相加并乘以两个其他度量的最后一个度量

时间:2016-11-05 04:38:26

标签: ssas mdx ssas-2012

以下是我的多维数据集维度用法的片段: TD Cube Dimension Usage

在" TD措施"我有

  • [A]" Billable Client Hours Current"。

In"人事措施"我有

  • [B]" FTE Count" (员工的工作量与.5相比 每周工作20小时的人)
  • [C]"预测FY End"对财政年度结束的预测
  • [D]"预测FYTD"对本财政年度当前期间的预测。

我需要在叶级别进行的计算是:

[A] [B] 的[C] / [d]

问题在于[A]具有更多维度[B],[C]和[D]。

所以如果这是我的数据:

Demo Data

我需要做的计算是:

<(>(15 * .05)+(5 * 1))//一段时间内的小时数乘以该月的FTE

X 2000/300 // FCFYE的最后一个孩子除以当前所选集合中FCFYTD的最后一个孩子。

这个计算结果可能会在接下来的一两周内发生一些变化,但这是他们希望做的主要概念。任何帮助编写MDX以在我的多维数据集中创建计算成员的帮助非常感谢。很抱歉,如果我遗漏了任何关键信息 - 我非常喜欢MDX菜鸟。

1 个答案:

答案 0 :(得分:0)

通过挖掘Chris Webb和Mosha的帖子以及在MSDN论坛上与一些人合作,我已经找到了解决方案。最后,我解决了我们不需要查询底层行以识别它们是否处于活动状态的业务,因为只要从DimMiscellaneous过滤了根功能,就不再需要根功能。但是为了帮助遇到类似问题的人,下面是完整的MDX。

//Only evaluate if they are active
CREATE HIDDEN UtilizedFTESummator;    
[Measures].[UtilizedFTESummator] = Iif([Measures].[Is Active For Utilization Value] > 0,[Measures].[Period FTE],NULL);    
NON_EMPTY_BEHAVIOR([Measures].[UtilizedFTESummator]) = [Measures].[Is Active For Utilization Value];  

//only include this measure if the underlying employee has values in their underlying data for active in utilization
CREATE MEMBER CURRENTCUBE.[Measures].[FTE Active Utilization]
AS
SUM
    (   
    EXISTING [Historical Personnel].[Employee Id].[Employee Id], 
    [Measures].[UtilizedFTESummator]
    ),VISIBLE=0;  

//Show weighted FTE by workdays 
CREATE MEMBER CURRENTCUBE.[Measures].[FTE MTD Active Utilization]
 AS SUM
(
    DESCENDANTS([Historical Personnel].[Employee Id].CURRENTMEMBER,[Historical Personnel].[Employee Id].[Employee Id]),
    (
    DIVIDE
        ( 
        SUM
            (   
            DESCENDANTS([Period].[Fiscal Period].CURRENTMEMBER,[Period].[Fiscal Period].[Fiscal Period]),
                    [Measures].[FTE Active Utilization]*[Measures].[Work Days In Month]
            )
        ,SUM(ROOT([Historical Personnel].[employee id].currentmember),[Measures].[Work Days In Month])
        ,0
        )
    )
);

//Use Weighted FTE for calculating the weighted value for each person (all periods aggregated) 
//Forecast Billable End Of Year has default aggregation of last child
CREATE MEMBER CURRENTCUBE.[Measures].[Annualized CBH Projected]
 AS DIVIDE 
(
    SUM
        (
        DESCENDANTS([Historical Personnel].[Employee Id].CURRENTMEMBER,[Historical Personnel].[Employee Id].[Employee Id]),
        [Measures].[Billable Client Hours Current] *
        (
        DIVIDE
            (
            [Measures].[Forecast Billable End Of Year]
            ,       
            [Measures].[Forecast Billable FTE]
            ,0
            )
        )
        *[Measures].[FTE MTD Active Utilization]
    )
    ,[Measures].[FTE MTD Active Utilization]
    ,0
    );

过滤Is Active For Utilization标志的用户的简化回答如下:

//Weight FTE by employee calculating FTE * workdays for each period and then dividing by the sum of days irrespective of filters on historical personnel or miscellaneous
CREATE MEMBER CURRENTCUBE.[Measures].[FTE MTD] 

 AS SUM
(
    DESCENDANTS([Historical Personnel].[Employee Id].CURRENTMEMBER,[Historical Personnel].[Employee Id].[Employee Id]),
    (
    DIVIDE
    (
    SUM
        (
        DESCENDANTS([Period].[Fiscal Period].CURRENTMEMBER,[Period].[Fiscal Period].[Fiscal Period]),[Measures].[Period FTE]*[Measures].[Work Days In Month]
        ) 
        ,
        SUM((ROOT([Historical Personnel].[employee id].currentmember),ROOT([Miscellaneous]),[Measures].[Work Days In Month]))
    ,0
    )
    )
);


//Weight by FTE with default agg for Forecast EOY being last child.
CREATE MEMBER CURRENTCUBE.[Measures].[Annualized CBH Projected]
 AS DIVIDE 
(
    SUM
        (
        DESCENDANTS([Historical Personnel].[Employee Id].CURRENTMEMBER,[Historical Personnel].[Employee Id].[Employee Id]),
        [Measures].[Billable Client Hours Current] *
        (
        DIVIDE
            (
            [Measures].[Forecast Billable End Of Year]
            ,       
            [Measures].[Forecast Billable FTE]
            ,0
            )
        )
        *[Measures].[FTE MTD]
    )
    ,[Measures].[FTE MTD]
    ,0
    );