1

我必须以一种奇怪的方式计算某些东西,它在大多数情况下都有效——无论是在叶子上还是在多个维度的更高级别的聚合中。但它没有给出一个特定维度的正确聚合值。

我目前拥有的是...

CREATE MEMBER CURRENTCUBE.[Measures].[Active Commitments]
 AS NULL,
FORMAT_STRING = '#,#', 
VISIBLE = 1;    

SCOPE (DESCENDANTS([Date Dimension].[Fiscal Year Hierarchy],,AFTER));     
[Measures].[Active Commitments] =
iif([Constituent Activity].[Type].currentMember.Properties("Name")="Correspondence",
    sum(([Commitment Dates].[Start Date], NULL: [Date Dimension].[Fiscal Year Hierarchy]), [Measures].[Commitment Count]),
    sum(([Commitment Dates].[First Funded Date], NULL: [Date Dimension].[Fiscal Year Hierarchy]), [Measures].[Commitment Count]))
        - sum(([Commitment Dates].[Stop Date],[Commitment].[Was Commitment Ever Active].[Sometime Active], NULL: [Date Dimension].[Fiscal Year Hierarchy]),  [Measures].[Commitment Count]); 
END SCOPE;

SCOPE (DESCENDANTS([Date Dimension].[Fiscal Year Hierarchy],,AFTER));
<Similar to above> 

如您所见,复杂性在于一种类型的“承诺”从 开始,[Start Date]而其他类型的“承诺”从[First Funded Date].

This fails whenever multiple members of [Constituent Activity]are selected because in such cases the use of currentMemberin the SCOPE statement is invalid. 例如,下面的 MDX 执行成功但输出#Error——

select  
    [Measures].[Active Commitments] on columns
    ,[Date Dimension].[Fiscal Year Hierarchy].[Fiscal Year].&[2011\12] on rows
from Compass3
where
    {[Constituent Activity].[Description].[XYZ]
    ,[Constituent Activity].[Description].[ABC]}

我认为我需要在 SCOPE 语句中编码的是递归......

if a single member of [Constituent Activity] is current
then use the calc as defined above
else use [Measures].[Active Commitments] = sum(all selected members of [Constituent Activity], [Measures].[Active Commitments])

...但是我该怎么写呢?

4

1 回答 1

1

您是否可以一直控制回到数据仓库/数据源视图?您可以在事实表中添加一个计算字段,以便在单元格级别具有 [承诺有效日期] 吗?然后你可以在多维数据集中做更简单的计数。

我发现从长远来看,在数据仓库中执行业务规则和进行业务计算会更高效、更容易。

于 2012-11-02T16:08:36.000 回答