MDX结果总计不正确

时间:2018-07-05 13:21:18

标签: mdx

我有以下MDX查询:

SELECT  { [Measures].[Work Order Count Housekeeping Per Sq Ft],  
          [Measures].[Work Order Count], 
          [Measures].[House Keeping Square Footage]} ON 0,  
        { (  [Location].[Entity Location Name].Members ) } ON 1 
FROM [Work Order] 
WHERE ( {  [Department].[Department Name].[Housekeeping]}, 
        { [Location].[Entity Location ID].[12280], [Location].[Entity Location ID].[14067], [Location].[Entity Location ID].[15092]}, 
        {  [Event Start Dates].[Date Key].[20160705] :  [Event Start Dates].[Date Key].[20180705]   }, 
        { [Owner Entity].[Entity ID].[12279], [Owner Entity].[Entity ID].[12280], [Owner Entity].[Entity ID].[14067], [Owner Entity].[Entity ID].[15092]}, 
        { [Work Order Days Open].[Days Open].[1] : [Work Order Days Open].[Days Open].[250] }, 
        { [Work Order Days Overdue].[Days Overdue].[1] : [Work Order Days Overdue].[Days Overdue].[250] } )

这就是我得到的结果:

enter image description here

我期望(并需要)所有值分别为6.42857、45和7,而不是我得到的值。

查询中我做错了什么?

1 个答案:

答案 0 :(得分:1)

ALL将始终为ALL

好像您想要一个新的ALL,它是WHERE子句中选择的3个成员的聚集。

您可以使用WITH子句创建ALLcustom成员:

WITH
SET LocationSet AS
{ [Location].[Entity Location ID].[12280], 
[Location].[Entity Location ID].[14067], 
[Location].[Entity Location ID].[15092]}
MEMBER Location].[Entity Location ID].[All].ALLcustom AS
AGGREGATE ( LocationSet )
SET [Locations] AS
{LocationSet,
 [Location].[Entity Location ID].[All].ALLcustom
}
SELECT  { [Measures].[Work Order Count Housekeeping Per Sq Ft],  
          [Measures].[Work Order Count], 
          [Measures].[House Keeping Square Footage]} ON 0,  
        [Locations] ON 1 
FROM [Work Order] 
WHERE ( {  [Department].[Department Name].[Housekeeping]}, 
        {  [Event Start Dates].[Date Key].[20160705] :  [Event Start Dates].[Date Key].[20180705]   }, 
        { [Owner Entity].[Entity ID].[12279], [Owner Entity].[Entity ID].[12280], [Owner Entity].[Entity ID].[14067], [Owner Entity].[Entity ID].[15092]}, 
        { [Work Order Days Open].[Days Open].[1] : [Work Order Days Open].[Days Open].[250] }, 
        { [Work Order Days Overdue].[Days Overdue].[1] : [Work Order Days Overdue].[Days Overdue].[250] } )