SSAS 多维数据集计算的成员总数错误

SSAS Cube calculated member totals wrong

我正在工作中学习。我在每张床上花费了 table 分钟。我想计算床的利用率百分比。我在 SSAS 2008 的多维数据集中创建了计算成员

CREATE MEMBER CURRENTCUBE.[Measures].UtilisationPercent
 AS avg( 
    crossjoin(
      descendants([bedlabel].[hierarchy].currentmember, [Bedlabel].[Bedlabel])
     ,descendants([Date].[date].currentmember, [Date].[Day])
    )
    ,[Measures].[Utilisation Mins]
   ) 
/ (24*60), 
FORMAT_STRING = "Percent", 
NON_EMPTY_BEHAVIOR = { [Utilisation Mins] }, 
VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'Bedstay'  ; 

如果我按 year/month 或 ward/bed 切片,这实际上工作正常。

但是多维数据集浏览器中显示的总利用率是错误的。我如何控制利用率总量的计算方式?我可以创建一个计算成员,使交叉连接在比叶子更高的级别上工作吗?

January 2011    Utilisation %

-- 在 MEZ 的评论后添加

好的,谢谢你的提示。我在这个

之后尝试了范围分配
SCOPE([Measures].[Utilisation Percentage]);     
    SCOPE([Date].[Date].MEMBERS);     
        SCOPE([bedlabel].[hierarchy].MEMBERS);     
            THIS = [Measures].[Utilisation Mins] / 
                    (60*24
                    * count(descendants([bedlabel].[hierarchy].currentmember, [Bedlabel].[Bedlabel])) 
                    * count(descendants([Date].[date].currentmember, [Date].[Day]))) ;     
        END SCOPE;     
    END SCOPE;     
END SCOPE;  

我得到了与交叉连接方法相同的结果。在 AS2008 中,范围分配结果和我的旧交叉连接方法之间没有区别吗?而且它仍然以我无法解释的超现实数字加起来。

可能是因为空元组造成了问题。使用 CoalesceEmpty 函数会将 EMPTY 单元格替换为 0。请尝试以下代码:

CREATE MEMBER CURRENTCUBE.[Measures].UtilisationPercent
 AS avg( crossjoin(descendants([bedlabel].[hierarchy].currentmember, [Bedlabel].[Bedlabel]), 
descendants([Date].[date].currentmember, [Date].[Day])), CoalesceEmpty([Measures].[Utilisation Mins], 0) )
/ (24*60), 
FORMAT_STRING = "Percent", 
NON_EMPTY_BEHAVIOR = { [Utilisation Mins] }, 
VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'Bedstay'  ;

由于 AVG 似乎不起作用,请检查以下脚本:

CREATE MEMBER CURRENTCUBE.[Measures].a
as 
SUM(
(descendants([bedlabel].[hierarchy].currentmember, [Bedlabel].[Bedlabel]) * descendants([Date].[date].currentmember, [Date].[Day])),
[Measures].[Utilisation Mins]),
NON_EMPTY_BEHAVIOR = { [Utilisation Mins] }, 
VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'Bedstay'  ; 

CREATE MEMBER CURRENTCUBE.[Measures].b 
as
COUNT(
(descendants([bedlabel].[hierarchy].currentmember, [Bedlabel].[Bedlabel]) * descendants([Date].[date].currentmember, [Date].[Day]))
,EXCLUDEEMPTY
),
NON_EMPTY_BEHAVIOR = { [Utilisation Mins] }, 
VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'Bedstay'  ; 

CREATE MEMBER CURRENTCUBE.[Measures].C
AS
[Measures].A/[Measures].B,
FORMAT_STRING = "Percent", 
NON_EMPTY_BEHAVIOR = { [Utilisation Mins] }, 
VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'Bedstay'  ; 

不是一个答案,而是一种深入了解正在发生的事情的方法。

请尝试添加以下度量:

CREATE MEMBER CURRENTCUBE.[Measures].UtilisationCount
 AS Count( 
    crossjoin(
      descendants([bedlabel].[hierarchy].currentmember, [Bedlabel].[Bedlabel])
     ,descendants([Date].[date].currentmember, [Date].[Day])
    )

然后在您的查询中添加这个新度量,在列上,希望 x、y、z、j、q 将是一些数字 - q 是什么?:

January 2011    UtilisationCount   Utilisation %

Bed1            x                   98.86%
Bed2            y                   88.38%
Bed3            z                   82.63%
Bed4            j                   94.67%
Total           q                   894.35%

这是 Sourav_Agasti 建议的排列组合,现在可以使用了。我认为 avg + nonemptycrossjoin 比 avg + coalesceempty 效果更好。

CREATE MEMBER CURRENTCUBE.[Measures].UtilisationPercent
 AS avg( nonemptycrossjoin(
       descendants([bedlabel].[hierarchy].currentmember,[bedlabel].[hierarchy].[Bedlabel])
       ,descendants([Date].[date].currentmember,[date].[date].[day]))
       , [Measures].[Utilisation Mins]/ (24*60)), 
FORMAT_STRING = "Percent", 
NON_EMPTY_BEHAVIOR = { [Utilisation Mins] }, 
VISIBLE = 1 ,  ASSOCIATED_MEASURE_GROUP = 'Bedstay'; 

根据 MEZ 的建议,这也有效。

SCOPE([Measures].[Utilisation Percentage]);
  scope ([bedlabel].[hierarchy].members);
      scope ([date].[date].members);      
          this = avg( nonemptycrossjoin(
            descendants([bedlabel].[hierarchy].currentmember,[bedlabel].[hierarchy].[Bedlabel])
            ,descendants([Date].[date].currentmember,[date].[date].[day]))
            , [Measures].[Utilisation Mins]/ (24*60)) ;
          non_empty_behavior (this) = [Utilisation Mins] ;
      end scope;
  end scope;
END SCOPE; 

与 AS2000 的不同之处在于我只需执行此操作,并将平均值指定为计算度量的聚合方法。我也没有多重层次结构。语法对我来说似乎更简单。

avg(nonemptycrossjoin(descendants([Unit].currentmember,[Unit].[Bed label]),descendants([Date].currentmember,[date].[day])), [Measures].[Utilisation Min]/ (24*60)) * 100'

感谢所有试图提供帮助的人!