首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SSAS中计算度量聚合的不同转折

SSAS中计算度量聚合的不同转折
EN

Stack Overflow用户
提问于 2012-11-02 13:57:07
回答 1查看 981关注 0票数 1

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

我现在有的是..。

代码语言:javascript
复制
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]

只要选择了多个[Constituent Activity]成员,此操作就会失败,因为在这种情况下,在SCOPE语句中使用currentMember是无效的。例如,以下MDX执行成功,但输出#Error --

代码语言:javascript
复制
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语句中编码的是递归...

代码语言:javascript
复制
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])

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

EN

回答 1

Stack Overflow用户

发布于 2012-11-03 00:08:36

您是否可以完全控制数据仓库/数据源视图?您是否可以将计算字段添加到事实数据表中,以便在单元格级别具有承付款有效日期?然后你就可以在立方体中做更简单的计数了。

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13190087

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档