【问题标题】:Using EXCEPT in Calculated member在计算成员中使用 EXCEPT
【发布时间】:2010-09-10 14:27:17
【问题描述】:

我在 MDX 查询中有以下计算成员:

MEMBER [Asset].[Class].[Fixed Income Derivatives (Inflation Linked)]
AS
(
    [Asset].[Class].&[Fixed Income],
    [Asset].[Sub Class].&[Derivatives],
    [Asset].[Sub Class Type].&[Inflation]
)

在查询中使用如下:

SELECT
{
  [Measures].[Market Value]
} ON 0,
NON EMPTY(
{ 
    [Asset].[Class].[Fixed Income Derivatives (Inflation Linked)]
} ON 1
FROM [Asset]

这很好用,当然也给了我所有与通胀挂钩的固定收益衍生品的市场价值。

我现在尝试添加第二个计算成员,这一次给我所有与通胀挂钩的固定收益衍生产品。我认为这就像第二个成员中的EXCEPT 一样简单,如下所示:

MEMBER [Asset].[Class].[Fixed Income Derivatives (Non Inflation Linked)]
AS
(
    [Asset].[Class].&[Fixed Income],
    [Asset].[Sub Class].&[Derivatives], 
    EXCEPT(
       [Asset].[Sub Class Type].[Sub Class Type], 
       [Asset].[Sub Class Type].&[Inflation]
    )
)

唉,运气不好 - 它会产生错误

该函数需要一个字符串或数字表达式 争论。元组集表达式是 用过。

这是一个令人困惑的信息,但对于 SSAS 课程来说是正常的。我确定我在正确的轨道上,只是有一点点错误,但我一辈子都无法发现问题。

【问题讨论】:

    标签: mdx ssas


    【解决方案1】:

    您只需要使用聚合函数即可实现您的目标而不会出错。

    如下更改计算的成员定义;

    MEMBER [Asset].[Class].[Fixed Income Derivatives (Non Inflation Linked)]
    AS
    (
        Aggregate
        (
           {[Asset].[Class].&[Fixed Income]} * 
           {[Asset].[Sub Class].&[Derivatives]} * 
           EXCEPT
           (
            [Asset].[Sub Class Type].[Sub Class Type], 
            [Asset].[Sub Class Type].&[Inflation]
           )
           ,Measures.CurrentMember
        )
    )
    

    【讨论】:

    • 非常感谢您的回答。困扰我好几个星期了。
    猜你喜欢
    • 1970-01-01
    • 2019-07-10
    • 1970-01-01
    • 2012-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-23
    • 1970-01-01
    相关资源
    最近更新 更多