Excel中的计算成员消失,具体取决于列顺序

时间:2017-03-16 15:14:36

标签: excel pivot-table mdx member

我正在尝试在Excel中为我的表格模型创建一个计算成员。我无法访问SQL中的模型,也无法更改代码。

我的目标是创建一个包含除亚特兰大以外的所有分支的计算成员。这是我在Excel中的mdx代码。

aggregate([Branch].[Branch].[Branch].MEMBERS)-[Branch].[Branch].&[101 - ATLANTA]

代码运行良好,如下面的数据透视表中所示。

Working ptable

使用MDX代码:

WITH
MEMBER [Branch].[Branch].[All].[ExclAtl] as aggregate([Branch].[Branch].
    [Branch].MEMBERS)-[Branch].[Branch].&[101 - ATLANTA]
SELECT NON EMPTY Hierarchize(DrilldownMember(CrossJoin({[Branch].[Branch].
    [All],[Branch].[Branch].[Branch].AllMembers}, {([Currency Type].
    [Currency Type].[All])}), [Branch].[Branch].[Branch].AllMembers, 
    [Currency Type].[Currency Type])) 
DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS  
FROM (SELECT ({[Branch].[Branch].[All].[caseTest], [Branch].[Branch].[All].
    [ExclAtl], [Branch].[Branch].&[101 - ATLANTA]},{[Currency Type].
    [Currency Type].&[Base (USD)]}) ON COLUMNS  FROM [Model]) 
WHERE ([Scale].[Currency Scale].[All],[Reserve Class].[Reserve Class Line].
    [All],[Param1].[Gross Ceded Net].&[Gross],[Measures].[Total Incurred]) 
CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, 
    FONT_FLAGS

问题是当我切换货币类型和分支列时,ExclAtl计算的成员不会显示。为什么是这样?有没有更好的方法在Excel中键入MDX代码,因此ExclAtl成员将显示我选择的任何列顺序?

Not working ptable

MDX代码(ExclAtl未显示)

WITH
MEMBER [Branch].[Branch].[All].[ExclAtl] as aggregate([Branch].[Branch].
    [Branch].MEMBERS)-[Branch].[Branch].&[101 - ATLANTA]
SELECT NON EMPTY Hierarchize(DrilldownMember(CrossJoin({[Currency Type].
    [Currency Type].[All],[Currency Type].[Currency Type].[Currency 
    Type].AllMembers}, {([Branch].[Branch].[All])}), [Currency Type].
    [Currency Type].[Currency Type].AllMembers, [Branch].[Branch])) 
DIMENSION PROPERTIES PARENT_UNIQUE_NAME,HIERARCHY_UNIQUE_NAME ON COLUMNS  
FROM (SELECT ({[Currency Type].[Currency Type].&[Base (USD)]},{[Branch].
    [Branch].[All].[caseTest], [Branch].[Branch].[All].[ExclAtl], [Branch].
    [Branch].&[101 - ATLANTA]}) ON COLUMNS  FROM [Model]) 
WHERE ([Scale].[Currency Scale].[All],[Reserve Class].[Reserve Class Line].
    [All],[Param1].[Gross Ceded Net].&[Gross],[Measures].[Total Incurred]) 
CELL PROPERTIES VALUE, FORMAT_STRING, LANGUAGE, BACK_COLOR, FORE_COLOR, 
    FONT_FLAGS

1 个答案:

答案 0 :(得分:0)

问题在于:

{([Branch].[Branch].[All])}

它不会返回[Branch]。[Branch]。[All]。[ExclAtl]成员。 您应该使用:

{([Branch].[Branch].AllMembers)}