在MDX中计算相同度量与“不同定义”的差异

时间:2014-06-16 04:00:41

标签: mysql mdx olap

我想计算相同度量的差异,但是使用了不同的定义' 这就是我尝试的但是它不起作用:

 WITH MEMBER [Measures].[Births] AS 
'[Measures].[type], [dimType].[TypeL].[Births]' 
 MEMBER [Measures].[Deaths] AS 
'[Measures].[type], [dimType].[TypeL].[Deaths]' 
 MEMBER [Measures].[Population_Growth] AS 
'[Measures].[Births] - [Measures].[Deaths]' 
 SELECT [Measures].[Population_Growth] ON COLUMNS, 
 [dimTime].[year] ON ROWS FROM [Population]

运行此查询时,我每年都会获得Population_Growth = 0。 我是MDX的新手,我不知道我做错了什么?

1 个答案:

答案 0 :(得分:0)

不确定。在MDX中,您已经评估了一个元组。如果您是单个成员,则不需要括号,但如果您不止一个,则需要它们。你能试试吗

WITH 
  MEMBER [Measures].[Births] AS ([Measures].[type], [dimType].[TypeL].[Births]) 
  MEMBER [Measures].[Deaths] AS ([Measures].[type], [dimType].[TypeL].[Deaths]) 
  MEMBER [Measures].[Population_Growth] AS [Measures].[Births] - [Measures].[Deaths]
SELECT
 [Measures].[Population_Growth] ON COLUMNS, 
 [dimTime].[year] ON ROWS 
FROM [Population]

如果这不起作用,可能是[类型]措施:

WITH 
  MEMBER [Measures].[Births] AS ([Measures].defaultmember, [dimType].[TypeL].[Births]) 
  MEMBER [Measures].[Deaths] AS ([Measures].defaultmember, [dimType].[TypeL].[Deaths]) 
  MEMBER [Measures].[Population_Growth] AS [Measures].[Births] - [Measures].[Deaths]
SELECT
 [Measures].[Population_Growth] ON COLUMNS, 
 [dimTime].[year] ON ROWS 
FROM [Population]

如果这不起作用,我们可以检查成员[dimType]。[TypeL]。[Births]是否合适。

WITH 
  MEMBER [Measures].[Population_Growth] AS [dimType].[TypeL].[Births].name
SELECT
 [Measures].[Population_Growth] ON COLUMNS, 
 [dimTime].[year] ON ROWS 
FROM [Population]

应该返回' Births'