我试图在MDX中编写一个简单的CASE语句,它根据特定的维度类型从不同的Fact表中返回Measure值,如下所示 -
WITH MEMBER [Measures].[Amount] AS
CASE [Dim Trx Type].[Trx Type Id].CURRENTMEMBER
WHEN [Dim Trx Type].[Trx Type Id].&[1] THEN [Measures].[Amount - Fact Sale]
WHEN [Dim Trx Type].[Trx Type Id].&[2] THEN [Measures].[Amount - Fact Sale]
WHEN [Dim Trx Type].[Trx Type Id].&[11] THEN [Measures].[Amount - Fact Usage]
END
然后我在MDX中使用[Measures]。[Amount]。这里的问题是我没有得到Type 11所需的值。如果我把我的情况移到第一行,我得到的是使用价值,有时是Sale。我无法理解的一种奇怪的行为。
有人可以帮忙吗?
答案 0 :(得分:1)
尝试使用CELL CALCULATION:
WITH MEMBER [Measures].[Amount] AS [Measures].[Amount - Fact Sale]
CELL CALCULATION [A] FOR '({[Dim Trx Type].[Trx Type Id].&[1], [Dim Trx Type].[Trx Type Id].&[2]}, [Measures].[Amount])' As ([Measures].[Amount - Fact Sale])
CELL CALCULATION [B] FOR '({[Dim Trx Type].[Trx Type Id].&[11]}, [Measures].[Amount])' As ([Measures].[Amount - Fact Usage])