MDX - 具有OR条件的不同维度上的多个过滤器

时间:2017-03-03 07:02:10

标签: mdx

我在查询MDX时遇到问题。

我有一个度量WEIGHT和两个维度DESTINATIONSOURCE具有相同的属性:NAMETYPE

我想回来:

SUM of WEIGHT 
where 
   DESTINATION.TYPE="A" 
   **OR** 
   SOURCE.TYPE="B" 
   **AND** 
      (DESTINATION.TYPE **<>** SOURCE.TYPE) 

如果试试这个:

SELECT NON EMPTY { 
   [Measures].[Weight] 
} 
ON COLUMNS, 
NON EMPTY { 
   ([Source].[Name].[Name].ALLMEMBERS * [Destination].[Name].[Name].ALLMEMBERS ) 
} 
ON ROWS 
FROM 
( SELECT ( { [Source].[Type].&[A] } ) ON COLUMNS FROM ( SELECT ( { [Destination].[Type].&[B] } )
     ON COLUMNS FROM [CUBE])) WHERE ( [Destination].[Type].&[B], [Source].[Type].&[A] ) 

但它不起作用。

在SQL中它看起来像

Select source.name, destination.name, sum(weight) from cube
where
(source.type = "A" or destination.type = "b")
and 
(source.type <> destination.type)
group by source.name, destination.name, source.type, destination.type

1 个答案:

答案 0 :(得分:0)

你的From部分有点乱。请尝试以下方法:

SELECT 
NON EMPTY { [Measures].[Weight] } ON COLUMNS, 
NON EMPTY { [Source].[Name].[Name].ALLMEMBERS * [Destination].[Name].[Name].ALLMEMBERS } ON ROWS 
FROM [CUBE]
WHERE ( {[Destination].[Type].&[B]} * {[Source].[Type].[All]} + {[Destination].[Type].[All]} * {[Source].[Type].&[A]} )