MDX计算尺寸成员基于另一个维度

时间:2014-02-13 18:31:24

标签: ssas mdx

有两个维度

[record].[record id]

[product].[product name]

[measures].[sales]

我想在记录维度中创建一个新的维度属性。

with member [record].[derived record id] as iif([product].[product name].[product name] 
in ('pen', 'eraser', 'notepad'), 0, [record].[record id].[record id])
select [measures].[sales] on 0, 
[record].[derived record id].[derived record id] on 1

您看到我要做的是将产品名称所在的行组合在一个选择列表中,并将其余部分保留原样。我可以在加载过程中执行此操作来创建此新属性,但如何在MDX中执行此操作?

提前致谢。

1 个答案:

答案 0 :(得分:2)

据我所知,您希望拥有[record].[record id]层次结构的计算成员,以便为当前产品名称成员之一的多维数据集中的所有度量提供值0。笔','橡皮擦'和'记事本'。为此,您可以使用以下MDX:

with member [record].[record id].[derived record id] -- note: you must name the hierarchy for calculated members
            as
            IIf([product].[product name].CurrentMember IS [product].[product name].[pen]
                or
                [product].[product name].CurrentMember IS [product].[product name].[eraser]
                or
                [product].[product name].CurrentMember IS [product].[product name].[notepad]
                ,
                0
                ,
                Measures.CurrentMember
               )
select [measures].[sales]
       on 0, 
       [record].[record id].[derived record id]
       on 1
  from [YourCube]