EXCEL中的MDX CASE声明


Just do it
2025-03-10 04:55:35 (12天前)


我正在访问Excel中的OLAP多维数据集中的数据,并尝试使用MDX查询在我的数据透视表中创建一个新的计算度量。

根据容器尺寸,我需要计算容量……

2 条回复
  1. 0# v-star*위위 | 2019-08-31 10-32



    您需要进行以下更改。代替




    1. WHEN [CONTAINER INSTANCE DIMENSION].[Container Size] = 20

    2. </code>


    你需要写




    1. WHEN [CONTAINER INSTANCE DIMENSION].[Container Size].CurrentMember.MEMBER_CAPTION = 20’.

    2. </code>


    在您的查询中,您希望根据容器大小的值选择乘数。为了获得当前正在评估的值,我们使用“Currentmember”。另外,您正在检查CURRENTMEMBER的“MEMBER_CAPTION”属性。您检查该值的方式将不起作用。 MDX将评估




    1. [CONTAINER INSTANCE DIMENSION].[Container Size] = 20

    2. </code>


    为true,因为您正在针对值评估维度属性。因此,您的Else子句给出了结果。



    以下是AdventureWorks上的示例。




    1. with member
      [Measures].[Internet Sales AmountCase]
      as
      case
      when [Product].[Size].CurrentMember.MEMBER_CAPTION = 38 then [Measures].[Internet Sales Amount]1
      when [Product].[Size].CurrentMember.MEMBER_CAPTION = 40 then [Measures].[Internet Sales Amount]
      2
      when [Product].[Size].CurrentMember.MEMBER_CAPTION = 46 then [Measures].[Internet Sales Amount]*3
      else -99
      end

    2. select
      {[Measures].[Internet Sales Amount],[Measures].[Internet Sales AmountCase]}
      on columns,

    3. ([Date].[Month of Year].[Month of Year],[Product].[Size].[38]:[Product].[Size].[70])
      on rows
      from [Adventure Works]

    4. </code>


    结果:




登录 后才能参与评论