SSAS中计算度量集合的另一种扭曲

SSAS中计算度量集合的另一种扭曲,ssas,mdx,aggregation,Ssas,Mdx,Aggregation,我不得不用一种奇怪的方式来计算一些东西,它在大多数情况下都是有效的——无论是在叶子上还是在多个维度的更高聚合级别上。但它没有为一个特定维度提供正确的聚合值 我现在拥有的是 CREATE MEMBER CURRENTCUBE.[Measures].[Active Commitments] AS NULL, FORMAT_STRING = '#,#', VISIBLE = 1; SCOPE (DESCENDANTS([Date Dimension].[Fiscal Year Hiera

我不得不用一种奇怪的方式来计算一些东西,它在大多数情况下都是有效的——无论是在叶子上还是在多个维度的更高聚合级别上。但它没有为一个特定维度提供正确的聚合值

我现在拥有的是

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> 
我想我需要在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])

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

您是否拥有返回数据仓库/数据源视图的所有控制权?您能否将计算字段添加到事实表中,以便在单元格级别具有[Commitment Active Date]?然后可以在多维数据集中进行更简单的计数


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

您是否拥有返回数据仓库/数据源视图的所有控制权?您能否将计算字段添加到事实表中,以便在单元格级别具有[Commitment Active Date]?然后可以在多维数据集中进行更简单的计数


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

谢谢比尔。我确实可以控制它,但它是我继承的一个已建立的立方体,并尝试尽可能靠近表面进行任何更改,以避免不必要的副作用。当前处理日期的结构非常复杂,因此添加另一个日期很棘手。谢谢比尔。我确实可以控制它,但它是我继承的一个已建立的立方体,并尝试尽可能靠近表面进行任何更改,以避免不必要的副作用。当前处理日期的结构相当复杂,因此添加另一个日期很棘手。
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])