【问题标题】:MDX How to group a setMDX 如何对集合进行分组
【发布时间】:2018-02-28 13:33:23
【问题描述】:

有人想办法解决我的问题吗?

我必须比较不同时期的一些值(30.12.2017 – 05.1.2018 / 30.12.2016 – 05.01.2017 / ...) 因此,我定义了一个 mdx,每个周期都有集合:

WITH 
SET [Period 1]  as  { STRTOMEMBER( "[Created].[Year -  Month -  Date].[Date].&[2017-12-30T00:00:00]" 
                : STRTOMEMBER( "[Created].[Year -  Month -  Date].[Date].&[2018-01-04T00:00:00]" )  }

SET [Period 2]  as  { STRTOMEMBER( "[Created].[Year -  Month -  Date].[Date].&[2016-12-30T00:00:00]" ) 
                : STRTOMEMBER( "[Created].[Year -  Month -  Date].[Date].&[2017-01-04T00:00:00]" )  }


SELECT 
    NON EMPTY {  [Measures].[Average Price], [Measures].[Average Position]  } ON COLUMNS,

    NON EMPTY (  {   [Period 1], [Period 2] }  ) on rows

FROM [Cube]

当我想要每天的结果时,这很有效,但是如何获得每个时期的值(平均值/总和)?需要的结果是有 2 行,一个用于 Period1,一个用于 Period2。

【问题讨论】:

    标签: sum set average mdx


    【解决方案1】:

    您应该能够对 WITH 子句中的每个函数应用聚合函数:

    WITH 
    SET [Period 1]  as  
        STRTOMEMBER( "[Created].[Year -  Month -  Date].[Date].&[2017-12-30T00:00:00]" 
        : 
        STRTOMEMBER( "[Created].[Year -  Month -  Date].[Date].&[2018-01-04T00:00:00]" )
    SET [Period 2]  as  
        STRTOMEMBER( "[Created].[Year -  Month -  Date].[Date].&[2016-12-30T00:00:00]" ) 
        : 
        STRTOMEMBER( "[Created].[Year -  Month -  Date].[Date].&[2017-01-04T00:00:00]" ) 
    MEMBER [Created].[Year -  Month -  Date].[All].[Period 1 Agg] AS  
       AGGREGATE( [Period 1]    )   
    MEMBER [Created].[Year -  Month -  Date].[All].[Period 2 Agg] AS  
       AGGREGATE( [Period 2]    )    
    SELECT 
        NON EMPTY {  [Measures].[Average Price], [Measures].[Average Position]  } ON 0,
        NON EMPTY 
         {  
           [Created].[Year -  Month -  Date].[All].[Period 1 Agg],
           [Created].[Year -  Month -  Date].[All].[Period 2 Agg] 
         }  on 1
    FROM [Cube];
    

    【讨论】:

    • 谢谢,但您的建议显示错误:“measures-hirachy 已在轴 0 上”。
    • @Katharina321 抱歉,我很懒 - 您需要将每个成员标记到现有的层次结构中 - 让我编辑(您可能需要调整,以便他们使用多维数据集中的正确 All 成员)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-14
    • 2014-06-07
    • 2021-07-16
    相关资源
    最近更新 更多